diff --git a/internal/gql/graphqlTypes.go b/internal/gql/graphqlTypes.go index 9d99cdb..42873c0 100644 --- a/internal/gql/graphqlTypes.go +++ b/internal/gql/graphqlTypes.go @@ -13,6 +13,7 @@ import ( types "git.kapelle.org/niklas/s3browser/internal/types" ) +var typesInit bool = false var graphqlDirType *graphql.Object var graphqlFileType *graphql.Object var graphqlLoginResultType *graphql.Object @@ -246,6 +247,8 @@ func GraphqlTypes() { }, }) + typesInit = true + } //loadFile helper func for using the dataloader to get a file diff --git a/internal/gql/schema.go b/internal/gql/schema.go index 3e4b75a..f9d2987 100644 --- a/internal/gql/schema.go +++ b/internal/gql/schema.go @@ -15,6 +15,10 @@ import ( //GraphqlSchema generate the schema with its root query and mutation func GraphqlSchema() (graphql.Schema, error) { + if !typesInit { + GraphqlTypes() + } + queryFields := graphql.Fields{ "files": &graphql.Field{ Type: graphql.NewNonNull(graphql.NewList(graphql.NewNonNull(graphqlFileType))),