Skip to content

Commit

Permalink
introspection: queryType
Browse files Browse the repository at this point in the history
  • Loading branch information
neelance committed Oct 19, 2016
1 parent cc348fa commit 1cac7e5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
28 changes: 26 additions & 2 deletions graphql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ var tests = []struct {
},

{
name: "StarWarsIntrospection",
name: "StarWarsIntrospection1",
schema: starwars.Schema,
resolver: &starwars.Resolver{},
query: `
Expand All @@ -526,7 +526,7 @@ var tests = []struct {
}
`,
result: `
{
{
"__schema": {
"types": [
{ "name": "Character" },
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions internal/exec/introspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1cac7e5

Please sign in to comment.