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

Adding compatibility check for all supported versions of graphql #156

Merged
merged 6 commits into from
Feb 19, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions .tav.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

graphql-0.11:
name: graphql
versions: "^0.9.0 || ^0.10.0 || ^0.11.0"
commands: mocha test/graphql.js test/graphql-v0.11.js

graphql-0.12:
name: graphql
versions: "^0.12.0 || ^0.13.0"
commands: mocha test/graphql.js test/graphql-v0.12.js
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ node_js:
- "6"
- "5"
- "4"
script:
- yarn test
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"jsnext:main": "./src/index.js",
"scripts": {
"bundle": "rollup -c && cp src/index.js.flow lib/graphql-tag.umd.js.flow",
"test": "mocha --require babel-register",
"test": "mocha test/graphql.js test/graphql-v0.12.js && tav --ci --compat",
"prepublish": "npm run bundle"
},
"repository": {
Expand All @@ -25,11 +25,12 @@
"babel-preset-es2015": "^6.9.0",
"babel-register": "^6.9.0",
"chai": "^4.0.2",
"graphql": "^0.11.0",
"graphql": "^0.13.0",
"mocha": "^3.4.1",
"rollup": "^0.45.0"
"rollup": "^0.45.0",
"test-all-versions": "^3.3.2"
},
"peerDependencies": {
"graphql": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0"
"graphql": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0"
}
}
137 changes: 137 additions & 0 deletions test/graphql-v0.11.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
const gqlRequire = require("../src");
const gqlDefault = require("../src").default;
const assert = require("chai").assert;

[gqlRequire, gqlDefault].forEach((gql, i) => {
describe(`gql ${i}`, () => {
it("is correct for a simple query", () => {
const ast = gql`
{
user(id: 5) {
firstName
lastName
}
}
`;

assert.equal(ast.kind, "Document");
assert.deepEqual(ast.definitions, [
{
kind: "OperationDefinition",
operation: "query",
name: null,
variableDefinitions: null,
directives: [],
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "Field",
alias: null,
name: {
kind: "Name",
value: "user"
},
arguments: [
{
kind: "Argument",
name: {
kind: "Name",
value: "id"
},
value: {
kind: "IntValue",
value: "5"
}
}
],
directives: [],
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "Field",
alias: null,
name: {
kind: "Name",
value: "firstName"
},
arguments: [],
directives: [],
selectionSet: null
},
{
kind: "Field",
alias: null,
name: {
kind: "Name",
value: "lastName"
},
arguments: [],
directives: [],
selectionSet: null
}
]
}
}
]
}
}
]);
});
it("is correct for a fragment", () => {
const ast = gql`
fragment UserFragment on User {
firstName
lastName
}
`;

assert.equal(ast.kind, "Document");
assert.deepEqual(ast.definitions, [
{
kind: "FragmentDefinition",
name: {
kind: "Name",
value: "UserFragment"
},
typeCondition: {
kind: "NamedType",
name: {
kind: "Name",
value: "User"
}
},
directives: [],
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "Field",
alias: null,
name: {
kind: "Name",
value: "firstName"
},
arguments: [],
directives: [],
selectionSet: null
},
{
kind: "Field",
alias: null,
name: {
kind: "Name",
value: "lastName"
},
arguments: [],
directives: [],
selectionSet: null
}
]
}
}
]);
});
});
});
138 changes: 138 additions & 0 deletions test/graphql-v0.12.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
const gqlRequire = require("../src");
const gqlDefault = require("../src").default;
const assert = require("chai").assert;

[gqlRequire, gqlDefault].forEach((gql, i) => {
describe(`gql ${i}`, () => {
it("is correct for a simple query", () => {
const ast = gql`
{
user(id: 5) {
firstName
lastName
}
}
`;

assert.equal(ast.kind, "Document");
assert.deepEqual(ast.definitions, [
{
kind: "OperationDefinition",
operation: "query",
name: undefined,
variableDefinitions: [],
directives: [],
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "Field",
alias: undefined,
name: {
kind: "Name",
value: "user"
},
arguments: [
{
kind: "Argument",
name: {
kind: "Name",
value: "id"
},
value: {
kind: "IntValue",
value: "5"
}
}
],
directives: [],
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "Field",
alias: undefined,
name: {
kind: "Name",
value: "firstName"
},
arguments: [],
directives: [],
selectionSet: undefined
},
{
kind: "Field",
alias: undefined,
name: {
kind: "Name",
value: "lastName"
},
arguments: [],
directives: [],
selectionSet: undefined
}
]
}
}
]
}
}
]);
});

it("is correct for a fragment", () => {
const ast = gql`
fragment UserFragment on User {
firstName
lastName
}
`;

assert.equal(ast.kind, "Document");
assert.deepEqual(ast.definitions, [
{
kind: "FragmentDefinition",
name: {
kind: "Name",
value: "UserFragment"
},
typeCondition: {
kind: "NamedType",
name: {
kind: "Name",
value: "User"
}
},
directives: [],
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "Field",
alias: undefined,
name: {
kind: "Name",
value: "firstName"
},
arguments: [],
directives: [],
selectionSet: undefined
},
{
kind: "Field",
alias: undefined,
name: {
kind: "Name",
value: "lastName"
},
arguments: [],
directives: [],
selectionSet: undefined
}
]
}
}
]);
});
});
});
Loading