diff --git a/request/graphql/schema/manager.go b/request/graphql/schema/manager.go index 26caaf5654..9d6313c384 100644 --- a/request/graphql/schema/manager.go +++ b/request/graphql/schema/manager.go @@ -160,5 +160,7 @@ func defaultTypes() []gql.Type { schemaTypes.CommitLinkObject, schemaTypes.CommitObject, schemaTypes.DeltaObject, + + schemaTypes.ExplainEnum, } } diff --git a/request/graphql/schema/types/types.go b/request/graphql/schema/types/types.go index 97fa9826b0..7bac33adb8 100644 --- a/request/graphql/schema/types/types.go +++ b/request/graphql/schema/types/types.go @@ -38,7 +38,8 @@ var ( }) ExplainEnum = gql.NewEnum(gql.EnumConfig{ - Name: "ExplainType", + Name: "ExplainType", + Description: "ExplainType is an enum selecting the type of explanation done by the @explain directive.", Values: gql.EnumValueConfigMap{ ExplainArgSimple: &gql.EnumValueConfig{ Value: ExplainArgSimple, @@ -48,7 +49,8 @@ var ( }) ExplainDirective *gql.Directive = gql.NewDirective(gql.DirectiveConfig{ - Name: ExplainLabel, + Name: ExplainLabel, + Description: "@explain is a directive that can be used to explain the query.", Args: gql.FieldConfigArgument{ ExplainArgNameType: &gql.ArgumentConfig{ Type: ExplainEnum, diff --git a/tests/integration/schema/client_test.go b/tests/integration/schema/client_test.go new file mode 100644 index 0000000000..850234d40c --- /dev/null +++ b/tests/integration/schema/client_test.go @@ -0,0 +1,49 @@ +// Copyright 2022 Democratized Data Foundation +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package schema + +import ( + "testing" + + schemaTypes "github.com/sourcenetwork/defradb/request/graphql/schema/types" +) + +// TestIntrospectionExplainTypeDefined tests that the introspection query returns a schema that +// defines the ExplainType enum. +func TestIntrospectionExplainTypeDefined(t *testing.T) { + test := RequestTestCase{ + Schema: []string{}, + IntrospectionRequest: ` + query IntrospectionQuery { + __schema { + types { + kind + name + description + } + } + } + `, + ContainsData: map[string]any{ + "__schema": map[string]any{ + "types": []any{ + map[string]any{ + "description": schemaTypes.ExplainEnum.Description(), + "kind": "ENUM", + "name": "ExplainType", + }, + }, + }, + }, + } + + ExecuteRequestTestCase(t, test) +}