I want to use the graphql type system language to create a schema that I can use for my application. In the application itself I want to hook into the resolver. The parsing of the type system files to a valid ast.Document is no problem
func parseSchemaToAST(t *testing.T, globalSchemaFile string) *ast.Document {
buffer, err := ioutil.ReadFile(globalSchemaFile)
if err != nil {
t.Fatalf("Error loading global schema file %v", err)
}
astDoc, err := parser.Parse(parser.ParseParams{
Source: string(buffer),
Options: parser.ParseOptions{
NoLocation: true,
},
})
if err != nil {
t.Fatalf("Parse failed: %v", err)
}
return astDoc
}
I also can transform this ast.Document back to the type system language. (via graphql/language/printer) But how should I do the transformation from ast.Document to graphql.Schema? In the graphql-js implementation I found a freaking useful function with the signature
function buildASTSchema(ast: Document): GraphQLSchema
What would be the graphql-go counterpart for that. I want to avoid a custom implementation