Skip to content

Commit fed0270

Browse files
committed
Add a better test for introspection
1 parent 9910e16 commit fed0270

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

features/bootstrap/GraphqlContext.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Behat\Gherkin\Node\PyStringNode;
1818
use Behatch\Context\RestContext;
1919
use Behatch\HttpCall\Request;
20+
use GraphQL\Type\Introspection;
2021

2122
/**
2223
* Context for GraphQL.
@@ -95,6 +96,15 @@ public function ISendTheGraphqlRequestWithOperation(string $operation)
9596
$this->sendGraphqlRequest();
9697
}
9798

99+
/**
100+
* @When I send the query to introspect the schema
101+
*/
102+
public function ISendTheQueryToIntrospectTheSchema()
103+
{
104+
$this->graphqlRequest = ['query' => Introspection::getIntrospectionQuery()];
105+
$this->sendGraphqlRequest();
106+
}
107+
98108
private function sendGraphqlRequest()
99109
{
100110
$this->request->setHttpHeader('Accept', null);

features/graphql/introspection.feature

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,13 @@ Feature: GraphQL introspection support
99
And the JSON node "errors[0].message" should be equal to "GraphQL query is not valid"
1010

1111
Scenario: Introspect the GraphQL schema
12-
When I send the following GraphQL request:
13-
"""
14-
{
15-
__schema {
16-
types {
17-
name
18-
}
19-
}
20-
}
21-
"""
12+
When I send the query to introspect the schema
2213
Then the response status code should be 200
2314
And the response should be in JSON
2415
And the header "Content-Type" should be equal to "application/json"
2516
And the JSON node "data.__schema.types" should exist
17+
And the JSON node "data.__schema.queryType.name" should be equal to "Query"
18+
And the JSON node "data.__schema.mutationType.name" should be equal to "Mutation"
2619

2720
Scenario: Introspect types
2821
When I send the following GraphQL request:

0 commit comments

Comments
 (0)