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

Add support for graphql 16 #374

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
49 changes: 27 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@
"build-fixtures": "npm run update-schema && npm run relay-compiler",
"lint": "eslint src test",
"prepublish": "npm run build",
"relay-compiler": "relay-compiler --watchman false --src test --schema test/fixtures/schema.graphql",
"relay-compiler": "relay-compiler",
"tdd": "jest --watch",
"test": "npm run build-fixtures && npm run lint && npm run testonly -- --coverage",
"testonly": "jest --runInBand --verbose",
"update-schema": "babel-node test/fixtures/updateSchema.js"
},
"relay": {
"src": "./test",
"schema": "./test/fixtures/schema.graphql",
"language": "javascript"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
Expand Down Expand Up @@ -55,28 +60,28 @@
"relay-runtime": ">=1.0.0"
},
"devDependencies": {
"@4c/babel-preset": "^7.4.1",
"@babel/cli": "^7.14.5",
"@babel/core": "^7.14.6",
"@babel/node": "^7.14.7",
"babel-jest": "^26.6.3",
"@4c/babel-preset": "^10.2.1",
"@babel/cli": "^7.23.9",
"@babel/core": "^7.23.9",
"@babel/node": "^7.23.9",
"babel-jest": "^29.7.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-relay": "^10.1.3",
"codecov": "^3.8.2",
"eslint": "^7.29.0",
"eslint-config-4catalyzer": "^1.2.0",
"eslint-config-4catalyzer-jest": "^2.1.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jest": "^23.20.0",
"eslint-plugin-prettier": "^3.4.0",
"graphql": "^15.5.1",
"graphql-relay": "^0.7.0",
"babel-plugin-relay": "^16.2.0",
"codecov": "^3.8.3",
"eslint": "^8.56.0",
"eslint-config-4catalyzer": "^1.5.0",
"eslint-config-4catalyzer-jest": "^2.3.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-prettier": "^5.1.3",
"graphql": "^16",
"graphql-relay": "^0.10.0",
"husky": "^4.3.8",
"jest": "^26.6.3",
"lint-staged": "^10.5.4",
"prettier": "^2.3.2",
"relay-compiler": "^10.1.3",
"relay-runtime": "^10.1.3"
"jest": "^29.7.0",
"lint-staged": "^15.2.0",
"prettier": "^3.2.4",
"relay-compiler": "^16.2.0",
"relay-runtime": "^16.2.0"
}
}
12 changes: 6 additions & 6 deletions src/createFetch.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { graphql } from 'graphql';

export default function createFetch({ schema, rootValue, contextValue }) {
return function fetchQuery(operation, variables) {
return graphql(
return function fetchQuery(operation, variableValues) {
return graphql({
schema,
operation.text,
source: operation.text,
rootValue,
contextValue,
variables,
).then((payload) => {
variableValues,
}).then((payload) => {
if (payload.errors) {
throw new Error(payload.errors);
throw new Error(payload.errors.join('\n'));
}

return payload;
Expand Down
2 changes: 1 addition & 1 deletion test/Network.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
graphql,
} from 'relay-runtime';

import { Network } from '../src';
import schema, { resetData } from './fixtures/schema';
import { Network } from '../src';

function executeQuery(environment, taggedNode) {
const query = getRequest(taggedNode);
Expand Down
36 changes: 18 additions & 18 deletions test/fixtures/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
type Mutation {
setWidgetName(input: SetWidgetNameInput!): SetWidgetNamePayload
}

"""An object with an ID"""
interface Node {
"""The id of the object."""
id: ID!
}

type Query {
"""Fetches an object given its ID"""
node(
Expand All @@ -24,18 +14,28 @@ type Query {
invalid: Widget
}

input SetWidgetNameInput {
name: String!
clientMutationId: String
}

type SetWidgetNamePayload {
widget: Widget
clientMutationId: String
"""An object with an ID"""
interface Node {
"""The id of the object."""
id: ID!
}

type Widget implements Node {
"""The ID of an object"""
id: ID!
name: String
}

type Mutation {
setWidgetName(input: SetWidgetNameInput!): SetWidgetNamePayload
}

type SetWidgetNamePayload {
widget: Widget
clientMutationId: String
}

input SetWidgetNameInput {
name: String!
clientMutationId: String
}
Loading