-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Provide tests for client introspection query (#1492)
## Relevant issue(s) Resolves #1099 ## Description Provide test that is somewhat isomorphic to the way that clients validate the resulting introspection schema. I've found that the client introspection query is the same accross Altair, GraphiQL, and Postman clients. ## How has this been tested? Linux & CI
- Loading branch information
1 parent
a49dbed
commit 8f72069
Showing
5 changed files
with
236 additions
and
0 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
tests/integration/schema/client_introspection/altair_graphiql_postman_2023.gql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
query IntrospectionQuery { | ||
__schema { | ||
queryType { name } | ||
mutationType { name } | ||
subscriptionType { name } | ||
types { | ||
...FullType | ||
} | ||
directives { | ||
name | ||
description | ||
locations | ||
args { | ||
...InputValue | ||
} | ||
} | ||
} | ||
} | ||
|
||
fragment FullType on __Type { | ||
kind | ||
name | ||
description | ||
fields(includeDeprecated: true) { | ||
name | ||
description | ||
args { | ||
...InputValue | ||
} | ||
type { | ||
...TypeRef | ||
} | ||
isDeprecated | ||
deprecationReason | ||
} | ||
inputFields { | ||
...InputValue | ||
} | ||
interfaces { | ||
...TypeRef | ||
} | ||
enumValues(includeDeprecated: true) { | ||
name | ||
description | ||
isDeprecated | ||
deprecationReason | ||
} | ||
possibleTypes { | ||
...TypeRef | ||
} | ||
} | ||
|
||
fragment InputValue on __InputValue { | ||
name | ||
description | ||
type { ...TypeRef } | ||
defaultValue | ||
} | ||
|
||
fragment TypeRef on __Type { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
ofType { | ||
kind | ||
name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
tests/integration/schema/client_introspection/one_many_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2023 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 client_introspection | ||
|
||
import ( | ||
_ "embed" | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration" | ||
) | ||
|
||
func TestClientIntrospectionWithOneToManySchema(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Actions: []any{ | ||
testUtils.SchemaUpdate{ | ||
Schema: ` | ||
type Book { | ||
name: String | ||
author: Author | ||
} | ||
type Author { | ||
name: String | ||
published: [Book] | ||
} | ||
`, | ||
}, | ||
testUtils.ClientIntrospectionRequest{ | ||
Request: clientIntrospectionQuery, | ||
// TODO: this should pass without error. | ||
// https://github.com/sourcenetwork/defradb/issues/1502 | ||
ExpectedError: "Unknown kind of type: ", | ||
// TODO: this should pass without error. | ||
// https://github.com/sourcenetwork/defradb/issues/1463 | ||
// ExpectedError: "InputFields are missing", | ||
}, | ||
}, | ||
} | ||
testUtils.ExecuteTestCase(t, []string{"Book", "Author"}, test) | ||
} |
32 changes: 32 additions & 0 deletions
32
tests/integration/schema/client_introspection/simple_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2023 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 client_introspection | ||
|
||
import ( | ||
_ "embed" | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration" | ||
) | ||
|
||
//go:embed altair_graphiql_postman_2023.gql | ||
var clientIntrospectionQuery string | ||
|
||
func TestClientIntrospectionBasic(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Actions: []any{ | ||
testUtils.ClientIntrospectionRequest{ | ||
Request: clientIntrospectionQuery, | ||
}, | ||
}, | ||
} | ||
testUtils.ExecuteTestCase(t, []string{}, test) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters