Skip to content

Commit

Permalink
fix(deps): Fix dependency patterns, graphql compatibility (#172)
Browse files Browse the repository at this point in the history
* Fix dependency versions

* GraphQL now uses quotes for comments

* Fix skipping empty Mutation on newer GraphQL versions

* Add test that empty schema works

* Upgrade flow

* Fix flow errors

* Formatting

* Lint
  • Loading branch information
benjie committed Feb 23, 2018
1 parent 552148e commit 0c4f9a5
Show file tree
Hide file tree
Showing 21 changed files with 6,935 additions and 4,290 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
"babel-plugin-transform-es2015-modules-commonjs": "^6.24.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-flow": "^6.23.0",
"flow-bin": "^0.52.0",
"flow-bin": "0.66.0",
"flow-copy-source": "^1.2.0",
"graphql": "^0.10.5",
"graphql": ">=0.9 <0.14",
"pg": ">=6.1.0 <8",
"sql-formatter": "^1.2.2"
},
"workspaces": [
Expand Down
8 changes: 0 additions & 8 deletions packages/graphile-build-pg/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
// @flow

// This script detects if you're running on Node v8 or above; if so it runs the
// code directly, otherwise it falls back to the babel-compiled version

/*::
// Trick flow into exporting the types
export type * from './node8plus';
*/

const isNode8Plus = process.versions.node.match(/^([89]|[1-9][0-9]+)\./);
// $FlowFixMe: ignore
module.exports = isNode8Plus ? require("./node8plus") : require("./node7minus");
3 changes: 1 addition & 2 deletions packages/graphile-build-pg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@
"jsonwebtoken": "^8.1.1",
"lodash": ">=4 <5",
"lru-cache": "4.1.1",
"pg": ">=6.1.0 <8",
"pg-range-parser": "^1.0.0",
"pg-sql2": "^1.0.0-beta.3",
"pluralize": "^5.0.0",
"postgres-interval": "1.1.1"
},
"peerDependencies": {
"pg": ">=6 <7"
"pg": ">=6.1.0 <8"
},
"devDependencies": {
"babel-cli": "^6.24.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/graphile-build-pg/src/inflections.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export type Inflector = {
[string]: (...input: Array<any>) => string,
};

function preventEmptyResult(obj) {
function preventEmptyResult<O: { [key: string]: () => string }>(
obj
): $ObjMap<O, <V>(V) => V> {
return Object.keys(obj).reduce((memo, key) => {
const fn = obj[key];
memo[key] = (...args) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`generates empty schema (with no Mutation type) 1`] = `
"\\"\\"\\"An object with a globally unique \`ID\`.\\"\\"\\"
interface Node {
\\"\\"\\"
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
\\"\\"\\"
id: ID!
}
\\"\\"\\"The root query type which gives access points into the data universe.\\"\\"\\"
type Query implements Node {
\\"\\"\\"
Exposes the root query type nested one level down. This is helpful for Relay 1
which can only query top level fields if they are in a particular form.
\\"\\"\\"
query: Query!
\\"\\"\\"
The root query type must be a \`Node\` to work well with Relay 1 mutations. This just resolves to \`query\`.
\\"\\"\\"
id: ID!
\\"\\"\\"Fetches an object given its globally unique \`ID\`.\\"\\"\\"
node(
\\"\\"\\"The globally unique \`ID\`.\\"\\"\\"
id: ID!
): Node
}
"
`;
22 changes: 14 additions & 8 deletions packages/graphile-build/__tests__/__snapshots__/enum.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,30 @@ exports[`generated schema 1`] = `
FOUR
}
# An object with a globally unique \`ID\`.
\\"\\"\\"An object with a globally unique \`ID\`.\\"\\"\\"
interface Node {
# A globally unique identifier. Can be used in various places throughout the system to identify this single value.
\\"\\"\\"
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
\\"\\"\\"
id: ID!
}
# The root query type which gives access points into the data universe.
\\"\\"\\"The root query type which gives access points into the data universe.\\"\\"\\"
type Query implements Node {
# Exposes the root query type nested one level down. This is helpful for Relay 1
# which can only query top level fields if they are in a particular form.
\\"\\"\\"
Exposes the root query type nested one level down. This is helpful for Relay 1
which can only query top level fields if they are in a particular form.
\\"\\"\\"
query: Query!
# The root query type must be a \`Node\` to work well with Relay 1 mutations. This just resolves to \`query\`.
\\"\\"\\"
The root query type must be a \`Node\` to work well with Relay 1 mutations. This just resolves to \`query\`.
\\"\\"\\"
id: ID!
# Fetches an object given its globally unique \`ID\`.
\\"\\"\\"Fetches an object given its globally unique \`ID\`.\\"\\"\\"
node(
# The globally unique \`ID\`.
\\"\\"\\"The globally unique \`ID\`.\\"\\"\\"
id: ID!
): Node
enum: MyEnum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Object {
`;

exports[`generated schema 1`] = `
"# A location in a connection that can be used for resuming pagination.
"\\"\\"\\"A location in a connection that can be used for resuming pagination.\\"\\"\\"
scalar Cursor
type Dummy {
Expand All @@ -62,24 +62,30 @@ type DummyEdge {
node: Dummy
}
# An object with a globally unique \`ID\`.
\\"\\"\\"An object with a globally unique \`ID\`.\\"\\"\\"
interface Node {
# A globally unique identifier. Can be used in various places throughout the system to identify this single value.
\\"\\"\\"
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
\\"\\"\\"
id: ID!
}
# The root query type which gives access points into the data universe.
\\"\\"\\"The root query type which gives access points into the data universe.\\"\\"\\"
type Query implements Node {
# Exposes the root query type nested one level down. This is helpful for Relay 1
# which can only query top level fields if they are in a particular form.
\\"\\"\\"
Exposes the root query type nested one level down. This is helpful for Relay 1
which can only query top level fields if they are in a particular form.
\\"\\"\\"
query: Query!
# The root query type must be a \`Node\` to work well with Relay 1 mutations. This just resolves to \`query\`.
\\"\\"\\"
The root query type must be a \`Node\` to work well with Relay 1 mutations. This just resolves to \`query\`.
\\"\\"\\"
id: ID!
# Fetches an object given its globally unique \`ID\`.
\\"\\"\\"Fetches an object given its globally unique \`ID\`.\\"\\"\\"
node(
# The globally unique \`ID\`.
\\"\\"\\"The globally unique \`ID\`.\\"\\"\\"
id: ID!
): Node
dummyConnection(first: Int, after: Cursor, sortBy: DummyConnectionSortBy): DummyConnection
Expand Down
44 changes: 28 additions & 16 deletions packages/graphile-build/__tests__/__snapshots__/watch.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,30 @@ exports[`generated schema n = 0, n = 3 1`] = `
n: Int!
}
# An object with a globally unique \`ID\`.
\\"\\"\\"An object with a globally unique \`ID\`.\\"\\"\\"
interface Node {
# A globally unique identifier. Can be used in various places throughout the system to identify this single value.
\\"\\"\\"
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
\\"\\"\\"
id: ID!
}
# The root query type which gives access points into the data universe.
\\"\\"\\"The root query type which gives access points into the data universe.\\"\\"\\"
type Query implements Node {
# Exposes the root query type nested one level down. This is helpful for Relay 1
# which can only query top level fields if they are in a particular form.
\\"\\"\\"
Exposes the root query type nested one level down. This is helpful for Relay 1
which can only query top level fields if they are in a particular form.
\\"\\"\\"
query: Query!
# The root query type must be a \`Node\` to work well with Relay 1 mutations. This just resolves to \`query\`.
\\"\\"\\"
The root query type must be a \`Node\` to work well with Relay 1 mutations. This just resolves to \`query\`.
\\"\\"\\"
id: ID!
# Fetches an object given its globally unique \`ID\`.
\\"\\"\\"Fetches an object given its globally unique \`ID\`.\\"\\"\\"
node(
# The globally unique \`ID\`.
\\"\\"\\"The globally unique \`ID\`.\\"\\"\\"
id: ID!
): Node
dummy: Dummy0
Expand All @@ -35,24 +41,30 @@ exports[`generated schema n = 0, n = 3 2`] = `
n: Int!
}
# An object with a globally unique \`ID\`.
\\"\\"\\"An object with a globally unique \`ID\`.\\"\\"\\"
interface Node {
# A globally unique identifier. Can be used in various places throughout the system to identify this single value.
\\"\\"\\"
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
\\"\\"\\"
id: ID!
}
# The root query type which gives access points into the data universe.
\\"\\"\\"The root query type which gives access points into the data universe.\\"\\"\\"
type Query implements Node {
# Exposes the root query type nested one level down. This is helpful for Relay 1
# which can only query top level fields if they are in a particular form.
\\"\\"\\"
Exposes the root query type nested one level down. This is helpful for Relay 1
which can only query top level fields if they are in a particular form.
\\"\\"\\"
query: Query!
# The root query type must be a \`Node\` to work well with Relay 1 mutations. This just resolves to \`query\`.
\\"\\"\\"
The root query type must be a \`Node\` to work well with Relay 1 mutations. This just resolves to \`query\`.
\\"\\"\\"
id: ID!
# Fetches an object given its globally unique \`ID\`.
\\"\\"\\"Fetches an object given its globally unique \`ID\`.\\"\\"\\"
node(
# The globally unique \`ID\`.
\\"\\"\\"The globally unique \`ID\`.\\"\\"\\"
id: ID!
): Node
dummy: Dummy3
Expand Down
7 changes: 7 additions & 0 deletions packages/graphile-build/__tests__/emptyMutation.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { printSchema } = require("graphql/utilities");
const { buildSchema, defaultPlugins } = require("../");

test("generates empty schema (with no Mutation type)", async () => {
const schema = await buildSchema([...defaultPlugins]);
expect(printSchema(schema)).toMatchSnapshot();
});

0 comments on commit 0c4f9a5

Please sign in to comment.