typesInit flag

This commit is contained in:
Djeeberjr 2022-02-07 15:53:14 +01:00
parent 48f770f703
commit 48c50a5b7e
2 changed files with 7 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import (
types "git.kapelle.org/niklas/s3browser/internal/types" types "git.kapelle.org/niklas/s3browser/internal/types"
) )
var typesInit bool = false
var graphqlDirType *graphql.Object var graphqlDirType *graphql.Object
var graphqlFileType *graphql.Object var graphqlFileType *graphql.Object
var graphqlLoginResultType *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 //loadFile helper func for using the dataloader to get a file

View File

@ -15,6 +15,10 @@ import (
//GraphqlSchema generate the schema with its root query and mutation //GraphqlSchema generate the schema with its root query and mutation
func GraphqlSchema() (graphql.Schema, error) { func GraphqlSchema() (graphql.Schema, error) {
if !typesInit {
GraphqlTypes()
}
queryFields := graphql.Fields{ queryFields := graphql.Fields{
"files": &graphql.Field{ "files": &graphql.Field{
Type: graphql.NewNonNull(graphql.NewList(graphql.NewNonNull(graphqlFileType))), Type: graphql.NewNonNull(graphql.NewList(graphql.NewNonNull(graphqlFileType))),