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

feat: graphql 17 support #927

Open
wants to merge 9 commits into
base: main
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
10 changes: 10 additions & 0 deletions .changeset/fast-socks-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@n1ru4l/graphql-live-query": minor
"@n1ru4l/graphql-live-query-patch": minor
"@n1ru4l/graphql-live-query-patch-jsondiffpatch": minor
"@n1ru4l/graphql-live-query-patch-json-patch": minor
"@n1ru4l/in-memory-live-query-store": minor
"@n1ru4l/socket-io-graphql-server": minor
---

add support for graphql-js 17
10 changes: 10 additions & 0 deletions .changeset/odd-vans-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@n1ru4l/graphql-live-query": minor
"@n1ru4l/graphql-live-query-patch": minor
"@n1ru4l/graphql-live-query-patch-jsondiffpatch": minor
"@n1ru4l/graphql-live-query-patch-json-patch": minor
"@n1ru4l/in-memory-live-query-store": minor
"@n1ru4l/socket-io-graphql-server": minor
---

Drop support for graphql-js `15.x.x`. Require at least graphql-js `^16.5.0`.
26 changes: 26 additions & 0 deletions .changeset/tidy-goats-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
"@n1ru4l/in-memory-live-query-store": minor
---

Drop the `execute` constructor argument option.
Please use `InMemoryLiveQueryStore.makeExecute` instead.

**Old**

```ts
import { InMemoryLiveQueryStore } from "@n1ru4l/in-memory-live-query-store";
import { execute as executeImplementation } from "graphql";

const liveQueryStore = new InMemoryLiveQueryStore({ execute });
const execute = liveQueryStore.execute;
```

**New**

```ts
import { InMemoryLiveQueryStore } from "@n1ru4l/in-memory-live-query-store";
import { execute as executeImplementation } from "graphql";

const liveQueryStore = new InMemoryLiveQueryStore();
const execute = liveQueryStore.makeExecute(executeImplementation);
```
12 changes: 10 additions & 2 deletions .github/workflows/ci-todo-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@ jobs:
ci:
name: CI
runs-on: ubuntu-latest
strategy:
matrix:
graphql_version:
- "16"
- "17.0.0-alpha.1"
steps:
- name: Checkout Repo
uses: actions/checkout@master
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup Node.js 14.x
- name: Setup Node.js 16.x
uses: actions/setup-node@master
with:
node-version: 14.x
node-version: 16.x

- name: Use GraphQL v${{matrix.graphql_version}}
run: node ./scripts/match-graphql.js ${{matrix.graphql_version}}

- name: Install Dependencies
run: yarn
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@ jobs:
ci:
name: CI
runs-on: ubuntu-latest
strategy:
matrix:
graphql_version:
- "16"
- "17.0.0-alpha.1"
steps:
- name: Checkout Repo
uses: actions/checkout@master
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup Node.js 14.x
- name: Setup Node.js 16.x
uses: actions/setup-node@master
with:
node-version: 14.x
node-version: 16.x

- name: Use GraphQL v${{matrix.graphql_version}}
run: node ./scripts/match-graphql.js ${{matrix.graphql_version}}

- name: Install Dependencies
run: yarn
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup Node.js 14.x
- name: Setup Node.js 16.x
uses: actions/setup-node@master
with:
node-version: 14.x
node-version: 16.x

- name: Install Dependencies
run: yarn
Expand Down
8 changes: 6 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";

module.exports = {
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
[
"@babel/preset-env",
{ targets: { node: process.versions.node.split(".")[0] } },
],
"@babel/preset-typescript",
],
plugins: ["@babel/plugin-proposal-class-properties"],
};
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const { resolve } = require("path");
const { pathsToModuleNameMapper } = require("ts-jest/utils");
const { pathsToModuleNameMapper } = require("ts-jest");
const CI = !!process.env.CI;

const ROOT_DIR = __dirname;
const TSCONFIG = resolve(ROOT_DIR, "tsconfig.json");
const tsconfig = require(TSCONFIG);

module.exports = {
transform: { "^.+\\.[jt]sx?$": "babel-jest" },
testEnvironment: "node",
rootDir: ROOT_DIR,
restoreMocks: true,
Expand Down
3 changes: 2 additions & 1 deletion jest.end2end.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { resolve } = require("path");
const { pathsToModuleNameMapper } = require("ts-jest/utils");
const { pathsToModuleNameMapper } = require("ts-jest");
const CI = !!process.env.CI;

const ROOT_DIR = __dirname;
Expand All @@ -8,6 +8,7 @@ const tsconfig = require(TSCONFIG);

module.exports = {
testEnvironment: "node",
transform: { "^.+\\.[jt]sx?$": "babel-jest" },
rootDir: ROOT_DIR,
restoreMocks: true,
reporters: ["default"],
Expand Down
4 changes: 2 additions & 2 deletions jest.project.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { resolve } = require("path");
const { pathsToModuleNameMapper } = require("ts-jest/utils");
const { pathsToModuleNameMapper } = require("ts-jest");

const ROOT_DIR = __dirname;
const TSCONFIG = resolve(ROOT_DIR, "tsconfig.json");
Expand All @@ -13,7 +13,7 @@ module.exports = ({ dirname, projectMode = true }) => {
...(CI || !projectMode
? {}
: { displayName: pkg.name.replace("@graphql-codegen/", "") }),
transform: { "^.+\\.tsx?$": "ts-jest" },
transform: { "^.+\\.[jt]sx?$": "babel-jest" },
testEnvironment: "node",
rootDir: dirname,
globals: {
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@
"@babel/preset-typescript": "7.17.12",
"@changesets/cli": "2.21.1",
"@types/jest": "27.5.1",
"babel-jest": "27.5.1",
"babel-jest": "28.1.0",
"bob-the-bundler": "1.5.1",
"chalk": "4.1.2",
"globby": "12.2.0",
"husky": "7.0.4",
"jest": "27.5.1",
"jest": "28.1.0",
"lint-staged": "12.4.1",
"patch-package": "6.4.7",
"prettier": "2.5.1",
"semver": "7.3.7",
"ts-jest": "27.1.5",
"ts-jest": "28.0.2",
"tsc-watch": "4.6.2",
"typescript": "4.5.5"
},
"resolutions": {
"graphql": "16.0.0-experimental-stream-defer.5"
"@graphql-tools/utils": "^8.6.12",
"graphql": "17.0.0-alpha.1"
},
"scripts": {
"build": "yarn ts:transpile && bob build",
Expand All @@ -40,7 +41,7 @@
"ts:transpile": "tsc --project tsconfig.build.json",
"prerelease": "yarn build",
"release": "changeset publish",
"postinstall": "patch-package",
"postinstall": "patch-package && node scripts/cjsify-graphql.js",
"prepare": "husky install",
"lint-staged": "lint-staged",
"release:canary": "(node scripts/canary-release.js && yarn build && yarn changeset publish --tag alpha) || echo Skipping Canary..."
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-live-query-patch-json-diff/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@n1ru4l/in-memory-live-query-store": "*"
},
"peerDependencies": {
"graphql": "^15.4.0 || ^16.0.0"
"graphql": "^16.5.0 || ^17.0.0"
},
"main": "dist/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-live-query-patch-json-patch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@n1ru4l/in-memory-live-query-store": "*"
},
"peerDependencies": {
"graphql": "^15.4.0 || ^16.0.0"
"graphql": "^16.5.0 || ^17.0.0"
},
"main": "dist/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-live-query-patch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@n1ru4l/in-memory-live-query-store": "*"
},
"peerDependencies": {
"graphql": "^15.4.0 || ^16.0.0"
"graphql": "^16.5.0 || ^17.0.0"
},
"main": "dist/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-live-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"real-time"
],
"peerDependencies": {
"graphql": "^15.4.0 || ^16.0.0"
"graphql": "^16.5.0 || ^17.0.0"
},
"main": "dist/index.js",
"module": "dist/esm/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@ import {
GraphQLID,
GraphQLList,
specifiedDirectives,
extendSchema,
} from "graphql";

const deferAST = parse(/* GraphQL */ `
directive @defer(
label: String
if: Boolean
) on FRAGMENT_SPREAD | INLINE_FRAGMENT
`);
const streamAST = parse(/* GraphQL */ `
directive @stream(label: String, initialCount: Int = 0, if: Boolean) on FIELD
`);

const createSchema = () => {
const GraphQLUserType = new GraphQLObjectType({
name: "User",
Expand Down Expand Up @@ -78,7 +89,7 @@ test("validation passes with usage of @live", () => {
});

test("validation passes with usage of @stream", () => {
const schema = createSchema();
const schema = extendSchema(createSchema(), streamAST);
const document = parse(/* GraphQL */ `
query foo {
users @stream(initialCount: 1) {
Expand All @@ -94,7 +105,7 @@ test("validation passes with usage of @stream", () => {
});

test("validation passes with usage of @defer", () => {
const schema = createSchema();
const schema = extendSchema(createSchema(), deferAST);
const document = parse(/* GraphQL */ `
query foo {
user {
Expand All @@ -113,7 +124,7 @@ test("validation passes with usage of @defer", () => {
});

test("validation fails with @live and @defer on the same operation", () => {
const schema = createSchema();
const schema = extendSchema(createSchema(), deferAST);
const document = parse(/* GraphQL */ `
query foo @live {
user {
Expand All @@ -136,7 +147,7 @@ test("validation fails with @live and @defer on the same operation", () => {
});

test("validation fails with @live and @stream on the same operation", () => {
const schema = createSchema();
const schema = extendSchema(createSchema(), streamAST);
const document = parse(/* GraphQL */ `
query foo @live {
users @stream(initialCount: 1) {
Expand All @@ -157,7 +168,7 @@ test("validation fails with @live and @stream on the same operation", () => {
});

test("validation passes with @live and @defer on different operations in the same document", () => {
const schema = createSchema();
const schema = extendSchema(createSchema(), streamAST);
const document = parse(/* GraphQL */ `
query foo @live {
users {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export const NoLiveMixedWithDeferStreamRule: ValidationRule = (context) => {
context.reportError(
new GraphQLError(
`Cannot mix "@${directiveNode.name.value}" with "@live".`,
directiveNode.name
{
nodes: directiveNode.name,
}
)
);
}
Expand Down
7 changes: 4 additions & 3 deletions packages/in-memory-live-query-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
"real-time"
],
"devDependencies": {
"graphql": "16.0.0-experimental-stream-defer.5"
"graphql": "16.0.0-experimental-stream-defer.5",
"jest-time-helpers": "0.1.0"
},
"dependencies": {
"@graphql-tools/utils": "^8.5.2",
"@graphql-tools/utils": "^8.6.12",
"@n1ru4l/graphql-live-query": "0.9.0",
"@repeaterjs/repeater": "^3.0.4"
},
"peerDependencies": {
"graphql": "^15.4.0 || ^16.0.0"
"graphql": "^16.5.0 || ^17.0.0"
},
"main": "dist/index.js",
"module": "dist/esm/index.js",
Expand Down
Loading