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 graphql@15.x. #3649

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"express": "4.17.1",
"fastify": "1.14.6",
"form-data": "2.5.1",
"graphql": "14.5.8",
"graphql": "15.0.0-alpha.2",
"graphql-subscriptions": "1.1.0",
"graphql-tag": "2.10.1",
"graphql-tools": "4.0.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-cache-control/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"graphql-extensions": "file:../graphql-extensions"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-engine-reporting/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"graphql-extensions": "file:../graphql-extensions"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-federation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"lodash.xorby": "^4.7.0"
},
"peerDependencies": {
"graphql": "^14.0.2"
"graphql": "^14.0.2 || ^15.0.0-alpha.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ type User @key(fields: "id") {

expect(schema.getQueryType()).toMatchInlineSnapshot(`
type Query {
""""""
abernix marked this conversation as resolved.
Show resolved Hide resolved
_entities(representations: [_Any!]!): [_Entity]!
_service: _Service!
rootField: String
Expand All @@ -164,6 +165,7 @@ type Query {

expect(schema.getQueryType()).toMatchInlineSnapshot(`
type QueryRoot {
""""""
abernix marked this conversation as resolved.
Show resolved Hide resolved
_entities(representations: [_Any!]!): [_Entity]!
_service: _Service!
rootField: String
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
"pretty-format": "^24.7.0"
},
"peerDependencies": {
"graphql": "^14.2.1"
"graphql": "^14.2.1 || ^15.0.0-alpha.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('ApolloGateway executor', () => {
});

expect(errors![0].message).toMatch(
'Variable "$first" got invalid value "3"; Expected type Int.',
'Variable "$first" got invalid value "3"; Int cannot represent non-integer value: "3"',
);
});
});
2 changes: 1 addition & 1 deletion packages/apollo-server-azure-functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
"apollo-server-integration-testsuite": "file:../apollo-server-integration-testsuite"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-server-cloud-functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
"apollo-server-integration-testsuite": "file:../apollo-server-integration-testsuite"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-server-cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"apollo-server-types": "file:../apollo-server-types"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-server-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
"ws": "^6.0.0"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-server-errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"node": ">=6"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-server-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
"apollo-server-integration-testsuite": "file:../apollo-server-integration-testsuite"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-server-fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
"apollo-server-integration-testsuite": "file:../apollo-server-integration-testsuite"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-server-hapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
"apollo-server-integration-testsuite": "file:../apollo-server-integration-testsuite"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
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() });
abernix marked this conversation as resolved.
Show resolved Hide resolved
return req.then(res => {
expect(res.status).toEqual(200);
expect(res.body.data.__schema.types[0].fields[0].name).toEqual(
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo-server-koa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
"apollo-server-integration-testsuite": "file:../apollo-server-integration-testsuite"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-server-lambda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
"apollo-server-integration-testsuite": "file:../apollo-server-integration-testsuite"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-server-plugin-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"apollo-server-types": "file:../apollo-server-types"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-server-plugin-response-cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
"apollo-server-types": "file:../apollo-server-types"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-server-testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
"apollo-server-types": "file:../apollo-server-types"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-server-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"apollo-server-env": "file:../apollo-server-env"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
"graphql-tools": "^4.0.0"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/apollo-tracing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"graphql-extensions": "file:../graphql-extensions"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}
2 changes: 1 addition & 1 deletion packages/graphql-extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"apollo-server-types": "file:../apollo-server-types"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0"
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0-alpha.2"
}
}