Skip to content

Commit

Permalink
Adding compatibility check for all supported versions of graphql (a…
Browse files Browse the repository at this point in the history
…pollographql#156)

* Adding compatibility testing for all `graphql` versions

* Running `tav` only in CI and latest otherwise

* Bumping to capture more versions of `graphql`

* Only check compatibility

* Try running `yarn test` instead

* Run `tav` _after_ testing latest
  • Loading branch information
jnwng committed Feb 19, 2018
1 parent 1994bba commit 78ca35f
Show file tree
Hide file tree
Showing 8 changed files with 635 additions and 179 deletions.
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

0 comments on commit 78ca35f

Please sign in to comment.