From db263662afae8b49cdb5a9041ccad1f1708b86a0 Mon Sep 17 00:00:00 2001 From: Andy Yu Date: Tue, 27 Feb 2024 09:26:56 +1300 Subject: [PATCH] wip --- execution_introspection_test.go | 45 +++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/execution_introspection_test.go b/execution_introspection_test.go index 9a290b1e..8fbeebf1 100644 --- a/execution_introspection_test.go +++ b/execution_introspection_test.go @@ -20,6 +20,10 @@ func TestIntrospectionQuery(t *testing.T) { name: String! } + input CinemaInput { + name: String! = "defaultName" + } + """ A bit like a film """ @@ -49,7 +53,12 @@ func TestIntrospectionQuery(t *testing.T) { movies: [Movie!]! somethingRandom: MovieOrCinema somePerson: Person - }` + } + + type Mutation { + createCinema(input: CinemaInput!): Cinema! + } + ` // Make sure schema merging doesn't break introspection mergedSchema, err := MergeSchemas(gqlparser.MustLoadSchema(&ast.Source{Name: "fixture", Input: schema})) @@ -454,10 +463,42 @@ func TestIntrospectionQuery(t *testing.T) { "queryType": { "name": "Query" }, - "mutationType": null, + "mutationType": { + "name": "Mutation" + }, "subscriptionType": null } } `, string(resp.Data)) }) + + t.Run("input fields", func(t *testing.T) { + query := gqlparser.MustLoadQuery(es.MergedSchema, `{ + __type(name: "CinemaInput") { + kind + name + inputFields { + name + defaultValue + } + } + }`) + ctx := testContextWithoutVariables(query.Operations[0]) + resp := es.ExecuteQuery(ctx) + + require.JSONEq(t, ` + { + "__type": { + "kind": "INPUT_OBJECT", + "name": "CinemaInput", + "inputFields": [ + { + "name": "name", + "defaultValue": "defaultName" + } + ] + } + } + `, string(resp.Data)) + }) }