Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preparations for [email protected]. #3712

Merged
merged 7 commits into from
Jan 29, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/source/testing/mocking.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ server.listen().then(({ url }) => {

## Mocking a schema using introspection

The GraphQL specification allows clients to introspect the schema with a [special set of types and fields](https://facebook.github.io/graphql/#sec-Introspection) that every schema must include. The results of a [standard introspection query](https://github.com/graphql/graphql-js/blob/master/src/utilities/introspectionQuery.js) can be used to generate an instance of GraphQLSchema which can be mocked as explained above.
The GraphQL specification allows clients to introspect the schema with a [special set of types and fields](https://facebook.github.io/graphql/#sec-Introspection) that every schema must include. The results of a [standard introspection query](https://github.com/graphql/graphql-js/blob/master/src/utilities/getIntrospectionQuery.js) can be used to generate an instance of GraphQLSchema which can be mocked as explained above.

This helps when you need to mock a schema defined in a language other than JS, for example Go, Ruby, or Python.

To convert an [introspection query](https://github.com/graphql/graphql-js/blob/master/src/utilities/introspectionQuery.js) result to a `GraphQLSchema` object, you can use the `buildClientSchema` utility from the `graphql` package.
To convert an [introspection query](https://github.com/graphql/graphql-js/blob/master/src/utilities/getIntrospectionQuery.js) result to a `GraphQLSchema` object, you can use the `buildClientSchema` utility from the `graphql` package.

```js
const { buildClientSchema } = require('graphql');
Expand Down
8 changes: 0 additions & 8 deletions packages/apollo-federation/src/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,40 @@ import {

export const KeyDirective = new GraphQLDirective({
name: 'key',
description: '',
locations: [DirectiveLocation.OBJECT, DirectiveLocation.INTERFACE],
args: {
fields: {
type: GraphQLNonNull(GraphQLString),
description: '',
},
},
});

export const ExtendsDirective = new GraphQLDirective({
name: 'extends',
description: '',
locations: [DirectiveLocation.OBJECT, DirectiveLocation.INTERFACE],
});

export const ExternalDirective = new GraphQLDirective({
name: 'external',
description: '',
locations: [DirectiveLocation.OBJECT, DirectiveLocation.FIELD_DEFINITION],
});

export const RequiresDirective = new GraphQLDirective({
name: 'requires',
description: '',
locations: [DirectiveLocation.FIELD_DEFINITION],
args: {
fields: {
type: GraphQLNonNull(GraphQLString),
description: '',
},
},
});

export const ProvidesDirective = new GraphQLDirective({
name: 'provides',
description: '',
locations: [DirectiveLocation.FIELD_DEFINITION],
args: {
fields: {
type: GraphQLNonNull(GraphQLString),
description: '',
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ function printDescription(
| GraphQLUnionType,
indentation: string = '',
): string {
if (!def.description) {
if (def.description == null) {
return '';
}

Expand Down
1 change: 0 additions & 1 deletion packages/apollo-federation/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export const entitiesField: GraphQLFieldConfig<any, any> = {
type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(AnyType))),
},
},
description: '',
resolve(_source, { representations }, context, info) {
return representations.map((reference: { __typename: string } & object) => {
const { __typename } = reference;
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-server-integration-testsuite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
GraphQLError,
GraphQLNonNull,
GraphQLScalarType,
introspectionQuery,
getIntrospectionQuery,
BREAK,
DocumentNode,
getOperationAST,
Expand Down Expand Up @@ -620,7 +620,7 @@ export default (createApp: CreateAppFunc, destroyApp?: DestroyAppFunc) => {
app = await createApp();
const req = request(app)
.post('/graphql')
.send({ query: introspectionQuery });
.send({ query: getIntrospectionQuery() });
return req.then(res => {
expect(res.status).toEqual(200);
expect(res.body.data.__schema.types[0].fields[0].name).toEqual(
Expand Down