FormatSchema method omits schema if schema.query is Query (code). I confirmed the same behavior in case of Mutation and Subscription.
Why does it omits Query, Mutation or Subscription from schema?
If the process to omit Query, Mutation and Subscription is not needed, I would like to create a PR and fix it.
Thank you.
package main
import (
"bytes"
"fmt"
"github.com/vektah/gqlparser/v2"
"github.com/vektah/gqlparser/v2/ast"
"github.com/vektah/gqlparser/v2/formatter"
)
func main() {
strSchema := `
schema {
query: Query
}
type Query {
noop: Boolean!
}`
var buf1 bytes.Buffer
f := formatter.NewFormatter(&buf1, formatter.WithIndent(" "))
schema, _ := gqlparser.LoadSchema(&ast.Source{
Input: strSchema,
})
f.FormatSchema(schema)
fmt.Println("formatted schema1:\n", buf1.String())
strSchema = `
schema {
query: RenamedQuery
}
type RenamedQuery {
noop: Boolean!
}`
var buf2 bytes.Buffer
f = formatter.NewFormatter(&buf2, formatter.WithIndent(" "))
schema, _ = gqlparser.LoadSchema(&ast.Source{
Input: strSchema,
})
f.FormatSchema(schema)
fmt.Println("formatted schema2:\n", buf2.String())
}
$ go run main.go
formatted schema1:
type Query {
noop: Boolean!
}
formatted schema2:
schema {
query: RenamedQuery
}
type RenamedQuery {
noop: Boolean!
}
FormatSchemamethod omitsschemaifschema.queryisQuery(code). I confirmed the same behavior in case ofMutationandSubscription.Why does it omits
Query,MutationorSubscriptionfromschema?If the process to omit
Query,MutationandSubscriptionis not needed, I would like to create a PR and fix it.Thank you.