From 48c50a5b7e01031df700753fb32c1c10821e88ab Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Mon, 7 Feb 2022 15:53:14 +0100 Subject: [PATCH] typesInit flag --- internal/gql/graphqlTypes.go | 3 +++ internal/gql/schema.go | 4 ++++ 2 files changed, 7 insertions(+) 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))),