diff --git a/graphql_test.go b/graphql_test.go index 9dff1914b2..91e6b1f5e4 100644 --- a/graphql_test.go +++ b/graphql_test.go @@ -513,7 +513,7 @@ var tests = []struct { }, { - name: "StarWarsIntrospection", + name: "StarWarsIntrospection1", schema: starwars.Schema, resolver: &starwars.Resolver{}, query: ` @@ -526,7 +526,7 @@ var tests = []struct { } `, result: ` - { + { "__schema": { "types": [ { "name": "Character" }, @@ -561,6 +561,30 @@ var tests = []struct { } `, }, + + { + name: "StarWarsIntrospection2", + schema: starwars.Schema, + resolver: &starwars.Resolver{}, + query: ` + { + __schema { + queryType { + name + } + } + } + `, + result: ` + { + "__schema": { + "queryType": { + "name": "Query" + } + } + } + `, + }, } func TestAll(t *testing.T) { diff --git a/internal/exec/introspection.go b/internal/exec/introspection.go index e8f8b84b32..81eeee6e92 100644 --- a/internal/exec/introspection.go +++ b/internal/exec/introspection.go @@ -138,11 +138,11 @@ func (r *schemaResolver) Types() []*typeResolver { } func (r *schemaResolver) QueryType() *typeResolver { - panic("TODO") + return &typeResolver{typ: r.schema.Types[r.schema.EntryPoints["query"]]} } func (r *schemaResolver) MutationType() *typeResolver { - panic("TODO") + return &typeResolver{typ: r.schema.Types[r.schema.EntryPoints["mutation"]]} } func (r *schemaResolver) Directives() []*directiveResolver {