File tree Expand file tree Collapse file tree 3 files changed +55
-2
lines changed
Expand file tree Collapse file tree 3 files changed +55
-2
lines changed Original file line number Diff line number Diff line change @@ -160,5 +160,7 @@ func defaultTypes() []gql.Type {
160160 schemaTypes .CommitLinkObject ,
161161 schemaTypes .CommitObject ,
162162 schemaTypes .DeltaObject ,
163+
164+ schemaTypes .ExplainEnum ,
163165 }
164166}
Original file line number Diff line number Diff line change 3838 })
3939
4040 ExplainEnum = gql .NewEnum (gql.EnumConfig {
41- Name : "ExplainType" ,
41+ Name : "ExplainType" ,
42+ Description : "ExplainType is an enum selecting the type of explanation done by the @explain directive." ,
4243 Values : gql.EnumValueConfigMap {
4344 ExplainArgSimple : & gql.EnumValueConfig {
4445 Value : ExplainArgSimple ,
4849 })
4950
5051 ExplainDirective * gql.Directive = gql .NewDirective (gql.DirectiveConfig {
51- Name : ExplainLabel ,
52+ Name : ExplainLabel ,
53+ Description : "@explain is a directive that can be used to explain the query." ,
5254 Args : gql.FieldConfigArgument {
5355 ExplainArgNameType : & gql.ArgumentConfig {
5456 Type : ExplainEnum ,
Original file line number Diff line number Diff line change 1+ // Copyright 2022 Democratized Data Foundation
2+ //
3+ // Use of this software is governed by the Business Source License
4+ // included in the file licenses/BSL.txt.
5+ //
6+ // As of the Change Date specified in that file, in accordance with
7+ // the Business Source License, use of this software will be governed
8+ // by the Apache License, Version 2.0, included in the file
9+ // licenses/APL.txt.
10+
11+ package schema
12+
13+ import (
14+ "testing"
15+
16+ schemaTypes "github.com/sourcenetwork/defradb/request/graphql/schema/types"
17+ )
18+
19+ // TestIntrospectionExplainTypeDefined tests that the introspection query returns a schema that
20+ // defines the ExplainType enum.
21+ func TestIntrospectionExplainTypeDefined (t * testing.T ) {
22+ test := RequestTestCase {
23+ Schema : []string {},
24+ IntrospectionRequest : `
25+ query IntrospectionQuery {
26+ __schema {
27+ types {
28+ kind
29+ name
30+ description
31+ }
32+ }
33+ }
34+ ` ,
35+ ContainsData : map [string ]any {
36+ "__schema" : map [string ]any {
37+ "types" : []any {
38+ map [string ]any {
39+ "description" : schemaTypes .ExplainEnum .Description (),
40+ "kind" : "ENUM" ,
41+ "name" : "ExplainType" ,
42+ },
43+ },
44+ },
45+ },
46+ }
47+
48+ ExecuteRequestTestCase (t , test )
49+ }
You can’t perform that action at this time.
0 commit comments