diff --git a/.github/workflows/pr-graphql-compat-check.yml b/.github/workflows/pr-graphql-compat-check.yml index c945e490d30..cd77d4741f5 100644 --- a/.github/workflows/pr-graphql-compat-check.yml +++ b/.github/workflows/pr-graphql-compat-check.yml @@ -4,8 +4,7 @@ on: # only on merge to main. # it's rare that this workflow would # show us an error, but when it does it's important! - branches: - - main + branches: [main, graphiql-v4] # don't run this regression suite if we don't need to paths-ignore: - '**.md' @@ -23,7 +22,8 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - release: ['15.5.3', '^15.8.0', '16.1.0', '16.2.0', '16.3.0'] + release: + ['15.5.3', '^15.8.0', '16.1.0', '16.2.0', '16.3.0', '17.0.0-alpha.5'] steps: - name: Checkout Code uses: actions/checkout@v4 diff --git a/examples/graphiql-webpack/package.json b/examples/graphiql-webpack/package.json index 57cb742cfed..bb3767363cc 100644 --- a/examples/graphiql-webpack/package.json +++ b/examples/graphiql-webpack/package.json @@ -11,7 +11,7 @@ "dependencies": { "@graphiql/plugin-code-exporter": "^4.0.0-alpha.0", "@graphiql/plugin-explorer": "^4.0.0-alpha.0", - "@graphiql/toolkit": "^0.9.2", + "@graphiql/toolkit": "^0.10.0", "@graphiql/react": "^1.0.0-alpha.1", "graphiql": "^4.0.0-alpha.2", "graphql": "^16.9.0", diff --git a/examples/monaco-graphql-nextjs/package.json b/examples/monaco-graphql-nextjs/package.json index 6a952a96861..2a8fb7ddea6 100644 --- a/examples/monaco-graphql-nextjs/package.json +++ b/examples/monaco-graphql-nextjs/package.json @@ -9,14 +9,14 @@ "start": "next start" }, "dependencies": { - "@graphiql/toolkit": "^0.9.2", + "@graphiql/toolkit": "^0.10.0", "graphql": "^16.9.0", "graphql-ws": "^5.5.5", "jsonc-parser": "^3.2.0", "marked": "^4.2.12", "monaco-editor": "^0.39.0", "monaco-editor-webpack-plugin": "^7.0.1", - "monaco-graphql": "^1.5.3", + "monaco-graphql": "^1.6.0", "next": "13.4.7", "prettier": "3.3.2", "react": "^18.2.0", diff --git a/examples/monaco-graphql-react-vite/package.json b/examples/monaco-graphql-react-vite/package.json index 3f38875515e..16c5fc627c8 100644 --- a/examples/monaco-graphql-react-vite/package.json +++ b/examples/monaco-graphql-react-vite/package.json @@ -3,12 +3,12 @@ "private": true, "version": "0.0.0", "dependencies": { - "@graphiql/toolkit": "^0.9.2", + "@graphiql/toolkit": "^0.10.0", "graphql": "^16.9.0", - "graphql-language-service": "^5.2.2", + "graphql-language-service": "^5.3.0", "jsonc-parser": "^3.2.0", "monaco-editor": "^0.39.0", - "monaco-graphql": "^1.5.3", + "monaco-graphql": "^1.6.0", "prettier": "3.3.2", "react": "^18.2.0", "react-dom": "^18.2.0" diff --git a/examples/monaco-graphql-webpack/package.json b/examples/monaco-graphql-webpack/package.json index e73f258bb7e..ba412189401 100644 --- a/examples/monaco-graphql-webpack/package.json +++ b/examples/monaco-graphql-webpack/package.json @@ -10,11 +10,11 @@ }, "dependencies": { "graphql": "^16.9.0", - "graphql-language-service": "^5.2.2", + "graphql-language-service": "^5.3.0", "json-schema": "^0.4.0", "jsonc-parser": "^3.2.0", "monaco-editor": "^0.39.0", - "monaco-graphql": "^1.5.3", + "monaco-graphql": "^1.6.0", "prettier": "3.3.2" }, "devDependencies": { diff --git a/package.json b/package.json index 68fa2ec4bb4..356758b4cbf 100644 --- a/package.json +++ b/package.json @@ -79,6 +79,7 @@ "dependencies": { "identity-obj-proxy": "^3.0.0", "babel-plugin-macros": "^3.1.0", + "graphql-http": "^1.22.1", "@babel/cli": "^7.21.0", "@babel/core": "^7.21.0", "@babel/plugin-proposal-class-properties": "^7.18.6", @@ -144,6 +145,7 @@ "resolutions": { "@babel/traverse": "^7.23.2", "vscode-languageserver-types": "3.17.3", - "markdown-it": "14.1.0" + "markdown-it": "14.1.0", + "graphql": "17.0.0-alpha.5" } } diff --git a/packages/cm6-graphql/CHANGELOG.md b/packages/cm6-graphql/CHANGELOG.md index 840ee2a0c4d..3a6cd89d9e7 100644 --- a/packages/cm6-graphql/CHANGELOG.md +++ b/packages/cm6-graphql/CHANGELOG.md @@ -1,5 +1,18 @@ # cm6-graphql +## 0.1.0 + +### Minor Changes + +- [#3682](https://github.com/graphql/graphiql/pull/3682) [`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931) Thanks [@yaacovCR](https://github.com/yaacovCR)! - Support v17 of `graphql-js` from `17.0.0-alpha.2` forward. + + Includes support for the latest incremental delivery response format. For further details, see https://github.com/graphql/defer-stream-wg/discussions/69. + +### Patch Changes + +- Updated dependencies [[`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931)]: + - graphql-language-service@5.3.0 + ## 0.0.15 ### Patch Changes diff --git a/packages/cm6-graphql/package.json b/packages/cm6-graphql/package.json index 5a33799ce55..52a45677e52 100644 --- a/packages/cm6-graphql/package.json +++ b/packages/cm6-graphql/package.json @@ -1,6 +1,6 @@ { "name": "cm6-graphql", - "version": "0.0.15", + "version": "0.1.0", "description": "GraphQL language support for CodeMirror 6", "scripts": { "build": "cm-buildhelper src/index.ts", @@ -16,7 +16,7 @@ "types": "dist/index.d.ts", "sideEffects": false, "dependencies": { - "graphql-language-service": "^5.2.1" + "graphql-language-service": "^5.3.0" }, "devDependencies": { "@codemirror/autocomplete": "6.2.0", @@ -30,7 +30,7 @@ "@lezer/highlight": "^1.0.0", "@lezer/lr": "^1.1.0", "esbuild": "0.18.10", - "graphql": "^16.9.0", + "graphql": "^17.0.0-alpha.5", "rollup": "^2.60.2", "rollup-plugin-dts": "^4.0.1", "rollup-plugin-esbuild": "^4.9.1", @@ -44,7 +44,7 @@ "@codemirror/state": "6.2.0", "@codemirror/view": "6.2.1", "@lezer/highlight": "^1.0.0", - "graphql": "^16.5.0" + "graphql": "^16.5.0 || ^17.0.0-alpha.2" }, "license": "MIT" } diff --git a/packages/codemirror-graphql/CHANGELOG.md b/packages/codemirror-graphql/CHANGELOG.md index cc6ddfc8019..3fa9165b6b8 100644 --- a/packages/codemirror-graphql/CHANGELOG.md +++ b/packages/codemirror-graphql/CHANGELOG.md @@ -1,5 +1,18 @@ # Change Log +## 2.1.0 + +### Minor Changes + +- [#3682](https://github.com/graphql/graphiql/pull/3682) [`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931) Thanks [@yaacovCR](https://github.com/yaacovCR)! - Support v17 of `graphql-js` from `17.0.0-alpha.2` forward. + + Includes support for the latest incremental delivery response format. For further details, see https://github.com/graphql/defer-stream-wg/discussions/69. + +### Patch Changes + +- Updated dependencies [[`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931)]: + - graphql-language-service@5.3.0 + ## 2.0.13 ### Patch Changes diff --git a/packages/codemirror-graphql/package.json b/packages/codemirror-graphql/package.json index 9fcfa64eacb..47c317563d4 100644 --- a/packages/codemirror-graphql/package.json +++ b/packages/codemirror-graphql/package.json @@ -1,6 +1,6 @@ { "name": "codemirror-graphql", - "version": "2.0.13", + "version": "2.1.0", "description": "GraphQL mode and helpers for CodeMirror.", "contributors": [ "Hyohyeon Jeong ", @@ -40,18 +40,18 @@ "peerDependencies": { "@codemirror/language": "6.0.0", "codemirror": "^5.65.3", - "graphql": "^15.5.0 || ^16.0.0" + "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0-alpha.2" }, "// TEMPORARILY PINNED until we fix graphql 15 support": "", "dependencies": { "@types/codemirror": "^0.0.90", - "graphql-language-service": "5.2.2" + "graphql-language-service": "5.3.0" }, "devDependencies": { "@codemirror/language": "^6.0.0", "codemirror": "^5.65.3", "cross-env": "^7.0.2", - "graphql": "^16.9.0", + "graphql": "^17.0.0-alpha.5", "rimraf": "^3.0.2", "sane": "2.0.0" } diff --git a/packages/codemirror-graphql/src/__tests__/lint-test.ts b/packages/codemirror-graphql/src/__tests__/lint-test.ts index 0df6a8a3c9e..e603873dd9b 100644 --- a/packages/codemirror-graphql/src/__tests__/lint-test.ts +++ b/packages/codemirror-graphql/src/__tests__/lint-test.ts @@ -11,7 +11,7 @@ import CodeMirror from 'codemirror'; import 'codemirror/addon/lint/lint'; import { readFileSync } from 'node:fs'; import { join } from 'node:path'; -import { GraphQLError, OperationDefinitionNode } from 'graphql'; +import { GraphQLError, OperationDefinitionNode, version } from 'graphql'; import '../lint'; import '../mode'; import { TestSchema } from './testSchema'; @@ -61,7 +61,13 @@ describe('graphql-lint', () => { const noMutationOperationRule = (context: any) => ({ OperationDefinition(node: OperationDefinitionNode) { if (node.operation === 'mutation') { - context.reportError(new GraphQLError('I like turtles.', node)); + context.reportError( + new GraphQLError( + 'I like turtles.', + // @ts-expect-error + parseInt(version, 10) > 16 ? { nodes: node } : node, + ), + ); } return false; }, diff --git a/packages/graphiql-plugin-code-exporter/CHANGELOG.md b/packages/graphiql-plugin-code-exporter/CHANGELOG.md index 4be547f592b..23581470018 100644 --- a/packages/graphiql-plugin-code-exporter/CHANGELOG.md +++ b/packages/graphiql-plugin-code-exporter/CHANGELOG.md @@ -26,6 +26,19 @@ - Updated dependencies [[`00415d2`](https://github.com/graphql/graphiql/commit/00415d2940c4d76a4a9e683e9fa0504ba97dd627), [`9baf1f0`](https://github.com/graphql/graphiql/commit/9baf1f0fc9f32404fbb8bf57b3d1c2c2c8778ddb), [`8ff87d7`](https://github.com/graphql/graphiql/commit/8ff87d7b6b3d5d12b539612a39ca3abf7e631106), [`82bc961`](https://github.com/graphql/graphiql/commit/82bc961a33c4e9da29dffb4a603035a4909f49ad), [`3c1a345`](https://github.com/graphql/graphiql/commit/3c1a345acd9bf07b45bc230009cb57c51c425673)]: - @graphiql/react@1.0.0-alpha.0 +## 3.1.0 + +### Minor Changes + +- [#3682](https://github.com/graphql/graphiql/pull/3682) [`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931) Thanks [@yaacovCR](https://github.com/yaacovCR)! - Support v17 of `graphql-js` from `17.0.0-alpha.2` forward. + + Includes support for the latest incremental delivery response format. For further details, see https://github.com/graphql/defer-stream-wg/discussions/69. + +### Patch Changes + +- Updated dependencies [[`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931)]: + - @graphiql/react@0.24.0 + ## 3.0.5 ### Patch Changes diff --git a/packages/graphiql-plugin-code-exporter/package.json b/packages/graphiql-plugin-code-exporter/package.json index 0b2c9783ab4..ff97b3ee4eb 100644 --- a/packages/graphiql-plugin-code-exporter/package.json +++ b/packages/graphiql-plugin-code-exporter/package.json @@ -42,14 +42,14 @@ }, "peerDependencies": { "@graphiql/react": "^1.0.0-alpha.0", - "graphql": "^15.5.0 || ^16.0.0", + "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0-alpha.2", "react": "^16.8.0 || ^17 || ^18", "react-dom": "^16.8.0 || ^17 || ^18" }, "devDependencies": { "@graphiql/react": "^1.0.0-alpha.0", "@vitejs/plugin-react": "^4.3.1", - "graphql": "^16.9.0", + "graphql": "^17.0.0-alpha.5", "postcss-nesting": "^10.1.7", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/packages/graphiql-plugin-explorer/CHANGELOG.md b/packages/graphiql-plugin-explorer/CHANGELOG.md index 99eb768ccc1..a2c13528535 100644 --- a/packages/graphiql-plugin-explorer/CHANGELOG.md +++ b/packages/graphiql-plugin-explorer/CHANGELOG.md @@ -26,6 +26,19 @@ - Updated dependencies [[`00415d2`](https://github.com/graphql/graphiql/commit/00415d2940c4d76a4a9e683e9fa0504ba97dd627), [`9baf1f0`](https://github.com/graphql/graphiql/commit/9baf1f0fc9f32404fbb8bf57b3d1c2c2c8778ddb), [`8ff87d7`](https://github.com/graphql/graphiql/commit/8ff87d7b6b3d5d12b539612a39ca3abf7e631106), [`82bc961`](https://github.com/graphql/graphiql/commit/82bc961a33c4e9da29dffb4a603035a4909f49ad), [`3c1a345`](https://github.com/graphql/graphiql/commit/3c1a345acd9bf07b45bc230009cb57c51c425673)]: - @graphiql/react@1.0.0-alpha.0 +## 3.2.0 + +### Minor Changes + +- [#3682](https://github.com/graphql/graphiql/pull/3682) [`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931) Thanks [@yaacovCR](https://github.com/yaacovCR)! - Support v17 of `graphql-js` from `17.0.0-alpha.2` forward. + + Includes support for the latest incremental delivery response format. For further details, see https://github.com/graphql/defer-stream-wg/discussions/69. + +### Patch Changes + +- Updated dependencies [[`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931)]: + - @graphiql/react@0.24.0 + ## 3.1.1 ### Patch Changes diff --git a/packages/graphiql-plugin-explorer/package.json b/packages/graphiql-plugin-explorer/package.json index 96536c0ed40..49890111acf 100644 --- a/packages/graphiql-plugin-explorer/package.json +++ b/packages/graphiql-plugin-explorer/package.json @@ -41,14 +41,14 @@ }, "peerDependencies": { "@graphiql/react": "^1.0.0-alpha.0", - "graphql": "^15.5.0 || ^16.0.0", + "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0-alpha.2", "react": "^16.8.0 || ^17 || ^18", "react-dom": "^16.8.0 || ^17 || ^18" }, "devDependencies": { "@graphiql/react": "^1.0.0-alpha.0", "@vitejs/plugin-react": "^4.3.1", - "graphql": "^16.9.0", + "graphql": "^17.0.0-alpha.5", "react": "^18.2.0", "react-dom": "^18.2.0", "typescript": "^4.6.3", diff --git a/packages/graphiql-react/CHANGELOG.md b/packages/graphiql-react/CHANGELOG.md index 344d87a5401..280ce16fba6 100644 --- a/packages/graphiql-react/CHANGELOG.md +++ b/packages/graphiql-react/CHANGELOG.md @@ -36,6 +36,21 @@ - [#3692](https://github.com/graphql/graphiql/pull/3692) [`82bc961`](https://github.com/graphql/graphiql/commit/82bc961a33c4e9da29dffb4a603035a4909f49ad) Thanks [@dimaMachina](https://github.com/dimaMachina)! - - prefer `location` over `window.location` - prefer `navigator` over `window.navigator` +## 0.24.0 + +### Minor Changes + +- [#3682](https://github.com/graphql/graphiql/pull/3682) [`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931) Thanks [@yaacovCR](https://github.com/yaacovCR)! - Support v17 of `graphql-js` from `17.0.0-alpha.2` forward. + + Includes support for the latest incremental delivery response format. For further details, see https://github.com/graphql/defer-stream-wg/discussions/69. + +### Patch Changes + +- Updated dependencies [[`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931)]: + - graphql-language-service@5.3.0 + - codemirror-graphql@2.1.0 + - @graphiql/toolkit@0.10.0 + ## 0.23.1 ### Patch Changes diff --git a/packages/graphiql-react/package.json b/packages/graphiql-react/package.json index e1117217b96..1733f83f0df 100644 --- a/packages/graphiql-react/package.json +++ b/packages/graphiql-react/package.json @@ -41,12 +41,12 @@ "types:check": "tsc --noEmit" }, "peerDependencies": { - "graphql": "^15.5.0 || ^16.0.0", + "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0-alpha.2", "react": "^16.8.0 || ^17 || ^18", "react-dom": "^16.8.0 || ^17 || ^18" }, "dependencies": { - "@graphiql/toolkit": "^0.9.2", + "@graphiql/toolkit": "^0.10.0", "@headlessui/react": "^1.7.15", "@radix-ui/react-dialog": "^1.0.4", "@radix-ui/react-dropdown-menu": "^2.0.5", @@ -55,20 +55,22 @@ "@types/codemirror": "^5.60.8", "clsx": "^1.2.1", "codemirror": "^5.65.3", - "codemirror-graphql": "^2.0.13", + "codemirror-graphql": "^2.1.0", "copy-to-clipboard": "^3.2.0", "framer-motion": "^10.0.0", - "graphql-language-service": "^5.2.2", + "get-value": "^3.0.1", + "graphql-language-service": "^5.3.0", "markdown-it": "^14.1.0", "set-value": "^4.1.0" }, "devDependencies": { - "@types/markdown-it": "^14.1.2", "@babel/helper-string-parser": "^7.19.4", "@testing-library/react": "14.0.0", + "@types/markdown-it": "^14.1.2", + "@types/get-value": "^3.0.5", "@types/set-value": "^4.0.1", "@vitejs/plugin-react": "^4.3.1", - "graphql": "^16.9.0", + "graphql": "^17.0.0-alpha.5", "postcss-nesting": "^10.1.7", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/packages/graphiql-react/src/execution.tsx b/packages/graphiql-react/src/execution.tsx index be1b8bcaced..5df69e39bbf 100644 --- a/packages/graphiql-react/src/execution.tsx +++ b/packages/graphiql-react/src/execution.tsx @@ -15,6 +15,7 @@ import { import { getFragmentDependenciesForAST } from 'graphql-language-service'; import { ReactNode, useCallback, useMemo, useRef, useState } from 'react'; import setValue from 'set-value'; +import getValue from 'get-value'; import { useAutoCompleteLeafs, useEditorContext } from './editor'; import { UseAutoCompleteLeafsArgs } from './editor/hooks'; @@ -343,8 +344,20 @@ type IncrementalResult = { incremental?: ReadonlyArray; label?: string; items?: ReadonlyArray> | null; + pending?: ReadonlyArray<{ id: string; path: ReadonlyArray }>; + completed?: ReadonlyArray<{ + id: string; + errors?: ReadonlyArray; + }>; + id?: string; + subPath?: ReadonlyArray; }; +const pathsMap = new WeakMap< + ExecutionResult, + Map> +>(); + /** * @param executionResult The complete execution result object which will be * mutated by merging the contents of the incremental result. @@ -352,22 +365,64 @@ type IncrementalResult = { * complete execution result. */ function mergeIncrementalResult( - executionResult: ExecutionResult, + executionResult: IncrementalResult, incrementalResult: IncrementalResult, ): void { - const path = ['data', ...(incrementalResult.path ?? [])]; - - if (incrementalResult.items) { - for (const item of incrementalResult.items) { - setValue(executionResult, path.join('.'), item); - // Increment the last path segment (the array index) to merge the next item at the next index - // eslint-disable-next-line unicorn/prefer-at -- cannot mutate the array using Array.at() - (path[path.length - 1] as number)++; + let path: ReadonlyArray | undefined = [ + 'data', + ...(incrementalResult.path ?? []), + ]; + + for (const result of [executionResult, incrementalResult]) { + if (result.pending) { + let paths = pathsMap.get(executionResult); + if (paths === undefined) { + paths = new Map(); + pathsMap.set(executionResult, paths); + } + + for (const { id, path: pendingPath } of result.pending) { + paths.set(id, ['data', ...pendingPath]); + } } } - if (incrementalResult.data) { - setValue(executionResult, path.join('.'), incrementalResult.data, { + const { items } = incrementalResult; + if (items) { + const { id } = incrementalResult; + if (id) { + path = pathsMap.get(executionResult)?.get(id); + if (path === undefined) { + throw new Error('Invalid incremental delivery format.'); + } + + const list = getValue(executionResult, path.join('.')); + list.push(...items); + } else { + path = ['data', ...(incrementalResult.path ?? [])]; + for (const item of items) { + setValue(executionResult, path.join('.'), item); + // Increment the last path segment (the array index) to merge the next item at the next index + // eslint-disable-next-line unicorn/prefer-at -- cannot mutate the array using Array.at() + (path[path.length - 1] as number)++; + } + } + } + + const { data } = incrementalResult; + if (data) { + const { id } = incrementalResult; + if (id) { + path = pathsMap.get(executionResult)?.get(id); + if (path === undefined) { + throw new Error('Invalid incremental delivery format.'); + } + const { subPath } = incrementalResult; + if (subPath !== undefined) { + path = [...path, ...subPath]; + } + } + setValue(executionResult, path.join('.'), data, { merge: true, }); } @@ -390,4 +445,16 @@ function mergeIncrementalResult( mergeIncrementalResult(executionResult, incrementalSubResult); } } + + if (incrementalResult.completed) { + // Remove tracking and add additional errors + for (const { id, errors } of incrementalResult.completed) { + pathsMap.get(executionResult)?.delete(id); + + if (errors) { + executionResult.errors ||= []; + (executionResult.errors as GraphQLError[]).push(...errors); + } + } + } } diff --git a/packages/graphiql-toolkit/CHANGELOG.md b/packages/graphiql-toolkit/CHANGELOG.md index b77a7a225cb..778d099fe80 100644 --- a/packages/graphiql-toolkit/CHANGELOG.md +++ b/packages/graphiql-toolkit/CHANGELOG.md @@ -1,5 +1,13 @@ # @graphiql/toolkit +## 0.10.0 + +### Minor Changes + +- [#3682](https://github.com/graphql/graphiql/pull/3682) [`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931) Thanks [@yaacovCR](https://github.com/yaacovCR)! - Support v17 of `graphql-js` from `17.0.0-alpha.2` forward. + + Includes support for the latest incremental delivery response format. For further details, see https://github.com/graphql/defer-stream-wg/discussions/69. + ## 0.9.2 ### Patch Changes diff --git a/packages/graphiql-toolkit/package.json b/packages/graphiql-toolkit/package.json index de12f431f79..7e11d002671 100644 --- a/packages/graphiql-toolkit/package.json +++ b/packages/graphiql-toolkit/package.json @@ -1,6 +1,6 @@ { "name": "@graphiql/toolkit", - "version": "0.9.2", + "version": "0.10.0", "description": "Utility to build a fetcher for GraphiQL", "contributors": [ "Rikki Schulte (https://rikki.dev)" @@ -24,13 +24,13 @@ "meros": "^1.1.4" }, "devDependencies": { - "graphql": "^16.9.0", + "graphql": "^17.0.0-alpha.5", "graphql-ws": "^5.5.5", "isomorphic-fetch": "^3.0.0", "subscriptions-transport-ws": "0.11.0" }, "peerDependencies": { - "graphql": "^15.5.0 || ^16.0.0", + "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0-alpha.2", "graphql-ws": ">= 4.5.0" }, "peerDependenciesMeta": { diff --git a/packages/graphiql/CHANGELOG.md b/packages/graphiql/CHANGELOG.md index f6e426e9584..1a6d8cfe524 100644 --- a/packages/graphiql/CHANGELOG.md +++ b/packages/graphiql/CHANGELOG.md @@ -148,6 +148,19 @@ - Updated dependencies [[`00415d2`](https://github.com/graphql/graphiql/commit/00415d2940c4d76a4a9e683e9fa0504ba97dd627), [`9baf1f0`](https://github.com/graphql/graphiql/commit/9baf1f0fc9f32404fbb8bf57b3d1c2c2c8778ddb), [`8ff87d7`](https://github.com/graphql/graphiql/commit/8ff87d7b6b3d5d12b539612a39ca3abf7e631106), [`82bc961`](https://github.com/graphql/graphiql/commit/82bc961a33c4e9da29dffb4a603035a4909f49ad), [`3c1a345`](https://github.com/graphql/graphiql/commit/3c1a345acd9bf07b45bc230009cb57c51c425673)]: - @graphiql/react@1.0.0-alpha.0 +## 3.5.0 + +### Minor Changes + +- [#3682](https://github.com/graphql/graphiql/pull/3682) [`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931) Thanks [@yaacovCR](https://github.com/yaacovCR)! - Support v17 of `graphql-js` from `17.0.0-alpha.2` forward. + + Includes support for the latest incremental delivery response format. For further details, see https://github.com/graphql/defer-stream-wg/discussions/69. + +### Patch Changes + +- Updated dependencies [[`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931)]: + - @graphiql/react@0.24.0 + ## 3.4.1 ### Patch Changes diff --git a/packages/graphiql/cypress/e2e/errors.cy.ts b/packages/graphiql/cypress/e2e/errors.cy.ts index dc9dd25c33f..b46511b3a8d 100644 --- a/packages/graphiql/cypress/e2e/errors.cy.ts +++ b/packages/graphiql/cypress/e2e/errors.cy.ts @@ -1,8 +1,12 @@ -import { version } from 'graphql'; +import { GraphQLError, version } from 'graphql'; describe('Errors', () => { it('Should show an error when the HTTP request fails', () => { - cy.visit('/?http-error=true'); + cy.intercept('/graphql', { + statusCode: 502, + body: 'Bad Gateway', + }); + cy.visit('/'); cy.assertQueryResult({ errors: [ { @@ -21,23 +25,27 @@ describe('Errors', () => { }); it('Should show an error when introspection fails', () => { - cy.visit('/?graphql-error=true'); + cy.intercept('/graphql', { + body: { errors: [new GraphQLError('Something unexpected happened...')] }, + }); + cy.visit('/'); cy.assertQueryResult({ errors: [{ message: 'Something unexpected happened...' }], }); }); it('Should show an error when the schema is invalid', () => { - cy.visit('/?bad=true'); + cy.intercept('/graphql', { fixture: 'bad-schema.json' }); + cy.visit('/'); /** * We can't use `cy.assertQueryResult` here because the stack contains line * and column numbers of the `index.umd.js` bundle which are not stable. */ cy.get('section.result-window').should(element => { expect(element.get(0).innerText).to.contain( - version.startsWith('16.') - ? 'Names must only contain [_a-zA-Z0-9] but \\"\\" does not.' - : 'Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but \\"\\" does not.', + version.startsWith('15') + ? 'Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but \\"\\" does not.' + : 'Names must only contain [_a-zA-Z0-9] but \\"\\" does not.', ); }); }); diff --git a/packages/graphiql/cypress/e2e/incremental-delivery.cy.ts b/packages/graphiql/cypress/e2e/incremental-delivery.cy.ts index 0ab5710b5ea..1ea0c0ed822 100644 --- a/packages/graphiql/cypress/e2e/incremental-delivery.cy.ts +++ b/packages/graphiql/cypress/e2e/incremental-delivery.cy.ts @@ -1,10 +1,9 @@ import { version } from 'graphql'; -let describeOrSkip = describe.skip; +let describeOrSkip: Mocha.SuiteFunction | Mocha.PendingSuiteFunction = describe; -// TODO: disable when defer/stream is merged to graphql -if (version.includes('stream')) { - describeOrSkip = describe; +if (parseInt(version, 10) < 17) { + describeOrSkip = describe.skip; } describeOrSkip('IncrementalDelivery support via fetcher', () => { @@ -52,7 +51,6 @@ describeOrSkip('IncrementalDelivery support via fetcher', () => { }, ], }, - hasNext: false, }; it('Expects slower streams to resolve in several increments, and the payloads to patch properly', () => { @@ -99,7 +97,6 @@ describeOrSkip('IncrementalDelivery support via fetcher', () => { 'Oops, this took 1 seconds longer than I thought it would!', }, }, - hasNext: false, }); }); @@ -164,7 +161,6 @@ describeOrSkip('IncrementalDelivery support via fetcher', () => { age: 1000, }, }, - hasNext: false, }); }); }); diff --git a/packages/graphiql/cypress/e2e/init.cy.ts b/packages/graphiql/cypress/e2e/init.cy.ts index 960faecd627..15f2b84e39d 100644 --- a/packages/graphiql/cypress/e2e/init.cy.ts +++ b/packages/graphiql/cypress/e2e/init.cy.ts @@ -49,7 +49,8 @@ describe('GraphiQL On Initialization', () => { cy.assertQueryResult(mockSuccess); }); it('Shows the expected error when the schema is invalid', () => { - cy.visit('/?bad=true'); + cy.intercept('/graphql', { fixture: 'bad-schema.json' }); + cy.visit('/'); cy.get('section.result-window').should(element => { expect(element.get(0).innerText).to.contain('Names must'); }); diff --git a/packages/graphiql/cypress/fixtures/bad-schema.json b/packages/graphiql/cypress/fixtures/bad-schema.json new file mode 100644 index 00000000000..b05417a54bf --- /dev/null +++ b/packages/graphiql/cypress/fixtures/bad-schema.json @@ -0,0 +1,99 @@ +{ + "data": { + "__schema": { + "queryType": { + "name": "Query" + }, + "mutationType": null, + "subscriptionType": null, + "types": [ + { + "kind": "OBJECT", + "name": "Query", + "description": null, + "fields": [ + { + "name": "user", + "description": null, + "args": [ + { + "name": "id", + "description": null, + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "defaultValue": null + } + ], + "type": { + "kind": "OBJECT", + "name": "", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "SCALAR", + "name": "ID", + "description": "", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "", + "description": null, + "fields": [ + { + "name": "name", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "SCALAR", + "name": "String", + "description": "", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + } + ], + "directives": [] + } + } +} diff --git a/packages/graphiql/package.json b/packages/graphiql/package.json index ca032b0fb6a..ecee724261f 100644 --- a/packages/graphiql/package.json +++ b/packages/graphiql/package.json @@ -44,20 +44,20 @@ "@graphiql/react": "^1.0.0-alpha.1" }, "peerDependencies": { - "graphql": "^15.5.0 || ^16.0.0", + "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0-alpha.2", "react": "^16.8.0 || ^17 || ^18", "react-dom": "^16.8.0 || ^17 || ^18" }, "devDependencies": { - "@graphiql/toolkit": "^0.9.2", + "@graphiql/toolkit": "^0.10.0", "@testing-library/jest-dom": "5.16.5", "@testing-library/react": "14.0.0", "@types/testing-library__jest-dom": "5.14.5", "cross-env": "^7.0.2", "cypress": "^13.13.2", "express": "^4.19.2", - "graphql": "^16.9.0", - "graphql-http": "^1.19.0", + "graphql": "^17.0.0-alpha.5", + "graphql-helix": "^1.13.0", "graphql-subscriptions": "^2.0.0", "postcss": "8.4.31", "postcss-import": "15.1.0", diff --git a/packages/graphiql/resources/renderExample.js b/packages/graphiql/resources/renderExample.js index b73a1631638..b61ea304b86 100644 --- a/packages/graphiql/resources/renderExample.js +++ b/packages/graphiql/resources/renderExample.js @@ -62,20 +62,10 @@ function updateURL() { function getSchemaUrl() { const isDev = /localhost$/.test(location.hostname); - if (!isDev) { - return '/.netlify/functions/graphql'; + if (isDev) { + return '/graphql'; } - // This supports an e2e test which ensures that invalid schemas do not load. - if (parameters.bad === 'true') { - return '/bad/graphql'; - } - if (parameters['http-error'] === 'true') { - return '/http-error/graphql'; - } - if (parameters['graphql-error'] === 'true') { - return '/graphql-error/graphql'; - } - return '/graphql'; + return '/.netlify/functions/graphql'; } // Render into the body. diff --git a/packages/graphiql/test/bad-schema.js b/packages/graphiql/test/bad-schema.js deleted file mode 100644 index a101f008652..00000000000 --- a/packages/graphiql/test/bad-schema.js +++ /dev/null @@ -1,97 +0,0 @@ -export const badSchema = { - __schema: { - queryType: { - name: 'Query', - }, - mutationType: null, - subscriptionType: null, - types: [ - { - kind: 'OBJECT', - name: 'Query', - description: null, - fields: [ - { - name: 'user', - description: null, - args: [ - { - name: 'id', - description: null, - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'SCALAR', - name: 'ID', - ofType: null, - }, - }, - defaultValue: null, - }, - ], - type: { - kind: 'OBJECT', - name: '', - ofType: null, - }, - isDeprecated: false, - deprecationReason: null, - }, - ], - inputFields: null, - interfaces: [], - enumValues: null, - possibleTypes: null, - }, - { - kind: 'SCALAR', - name: 'ID', - description: '', - fields: null, - inputFields: null, - interfaces: null, - enumValues: null, - possibleTypes: null, - }, - { - kind: 'OBJECT', - name: '', - description: null, - fields: [ - { - name: 'name', - description: null, - args: [], - type: { - kind: 'NON_NULL', - name: null, - ofType: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - }, - isDeprecated: false, - deprecationReason: null, - }, - ], - inputFields: null, - interfaces: [], - enumValues: null, - possibleTypes: null, - }, - { - kind: 'SCALAR', - name: 'String', - description: '', - fields: null, - inputFields: null, - interfaces: null, - enumValues: null, - possibleTypes: null, - }, - ], - directives: [], - }, -}; diff --git a/packages/graphiql/test/e2e-server.js b/packages/graphiql/test/e2e-server.js index 003b5ebd013..4357c2da799 100644 --- a/packages/graphiql/test/e2e-server.js +++ b/packages/graphiql/test/e2e-server.js @@ -10,34 +10,67 @@ import { createServer } from 'node:http'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import express from 'express'; -import { GraphQLError } from 'graphql'; -import { createHandler } from 'graphql-http/lib/use/express'; import { useServer } from 'graphql-ws/lib/use/ws'; import { WebSocketServer } from 'ws'; +import { execute, experimentalExecuteIncrementally, version } from 'graphql'; +import { + getGraphQLParameters, + processRequest, + sendResult, +} from 'graphql-helix'; // update when `graphql-http` is upgraded to support multipart requests for incremental delivery https://github.com/graphql/graphiql/pull/3682#discussion_r1715545279 import { schema } from './schema.js'; -import { badSchema } from './bad-schema.js'; const app = express(); -// Server -app.post('/graphql', createHandler({ schema })); -app.get('/graphql', createHandler({ schema })); +const customExecute = + parseInt(version, 10) > 16 + ? async (...args) => { + const result = await experimentalExecuteIncrementally(...args); -app.post('/bad/graphql', (_req, res, next) => { - res.json({ data: badSchema }); - next(); -}); + if (!('subsequentResults' in result)) { + return result; + } -app.post('/http-error/graphql', (_req, res, next) => { - res.status(502).send('Bad Gateway'); - next(); -}); + const { initialResult, subsequentResults } = result; + if (typeof subsequentResults[Symbol.asyncIterator] !== 'function') { + return result; + } -app.post('/graphql-error/graphql', (_req, res, next) => { - res.json({ errors: [new GraphQLError('Something unexpected happened...')] }); - next(); -}); + return (async function* () { + yield initialResult; + yield* subsequentResults; + })(); + } + : execute; + +async function handler(req, res) { + const request = { + body: req.body, + headers: req.headers, + method: req.method, + query: req.query, + }; + + const { operationName, query, variables } = getGraphQLParameters(request); + + const result = await processRequest({ + operationName, + query, + variables, + request, + schema, + execute: customExecute, + }); + + sendResult(result, res); +} + +// Server +app.use(express.json()); + +app.post('/graphql', handler); +app.get('/graphql', handler); // On CI we test the UMD build if (process.env.CI === 'true') { diff --git a/packages/graphiql/test/schema.js b/packages/graphiql/test/schema.js index ec8d99ff122..5d9173a4563 100644 --- a/packages/graphiql/test/schema.js +++ b/packages/graphiql/test/schema.js @@ -20,8 +20,17 @@ import { GraphQLString, GraphQLID, GraphQLList, + GraphQLDeferDirective, + GraphQLStreamDirective, + specifiedDirectives, + version, } from 'graphql'; +const directives = + parseInt(version, 10) > 16 + ? [...specifiedDirectives, GraphQLDeferDirective, GraphQLStreamDirective] + : specifiedDirectives; + // Test Schema const TestEnum = new GraphQLEnumType({ name: 'TestEnum', @@ -387,4 +396,5 @@ export const schema = new GraphQLSchema({ mutation: TestMutationType, subscription: TestSubscriptionType, description: 'This is a test schema for GraphiQL', + directives, }); diff --git a/packages/graphiql/vite.config.mts b/packages/graphiql/vite.config.mts index 402570f6e10..f6f830074f4 100644 --- a/packages/graphiql/vite.config.mts +++ b/packages/graphiql/vite.config.mts @@ -5,6 +5,8 @@ import commonjs from 'vite-plugin-commonjs'; const umdConfig = defineConfig({ define: { + // graphql v17 + 'globalThis.process.env.NODE_ENV': 'true', // https://github.com/graphql/graphql-js/blob/16.x.x/website/docs/tutorials/going-to-production.md#vite 'globalThis.process': 'true', 'process.env.NODE_ENV': '"production"', @@ -56,9 +58,6 @@ const esmConfig = defineConfig({ open: false, proxy: { '/graphql': 'http://localhost:8080', - '/bad/graphql': 'http://localhost:8080', - '/http-error/graphql': 'http://localhost:8080', - '/graphql-error/graphql': 'http://localhost:8080', '/subscriptions': { target: 'ws://localhost:8081', ws: true, @@ -69,6 +68,17 @@ const esmConfig = defineConfig({ }); function htmlPlugin(): PluginOption { + const htmlForVite = /* HTML */ ` + + + `; + return { name: 'html-replace-umd-with-src', transformIndexHtml: { @@ -80,19 +90,7 @@ function htmlPlugin(): PluginOption { html.indexOf(start), html.indexOf(end) + end.length, ); - return html.replace( - contentToReplace, - /* HTML */ ` - - - `, - ); + return html.replace(contentToReplace, htmlForVite); }, }, }; diff --git a/packages/graphql-language-service-cli/CHANGELOG.md b/packages/graphql-language-service-cli/CHANGELOG.md index 3ab48753318..0a2e4bf41b5 100644 --- a/packages/graphql-language-service-cli/CHANGELOG.md +++ b/packages/graphql-language-service-cli/CHANGELOG.md @@ -1,5 +1,19 @@ # graphql-language-service-cli +## 3.5.0 + +### Minor Changes + +- [#3682](https://github.com/graphql/graphiql/pull/3682) [`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931) Thanks [@yaacovCR](https://github.com/yaacovCR)! - Support v17 of `graphql-js` from `17.0.0-alpha.2` forward. + + Includes support for the latest incremental delivery response format. For further details, see https://github.com/graphql/defer-stream-wg/discussions/69. + +### Patch Changes + +- Updated dependencies [[`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931)]: + - graphql-language-service-server@2.14.0 + - graphql-language-service@5.3.0 + ## 3.4.2 ### Patch Changes diff --git a/packages/graphql-language-service-cli/package.json b/packages/graphql-language-service-cli/package.json index 5bb897de2ac..a7e321c08a1 100644 --- a/packages/graphql-language-service-cli/package.json +++ b/packages/graphql-language-service-cli/package.json @@ -1,6 +1,6 @@ { "name": "graphql-language-service-cli", - "version": "3.4.2", + "version": "3.5.0", "description": "An interface for building GraphQL language services for IDEs", "contributors": [ "Hyohyeon Jeong ", @@ -32,16 +32,16 @@ "LSP" ], "peerDependencies": { - "graphql": "^15.5.0 || ^16.0.0" + "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0-alpha.2" }, "dependencies": { "@babel/polyfill": "^7.12.1", "@types/yargs": "16.0.5", - "graphql-language-service": "^5.2.2", - "graphql-language-service-server": "^2.13.2", + "graphql-language-service": "^5.3.0", + "graphql-language-service-server": "^2.14.0", "yargs": "^16.2.0" }, "devDependencies": { - "graphql": "^16.9.0" + "graphql": "^17.0.0-alpha.5" } } diff --git a/packages/graphql-language-service-server/CHANGELOG.md b/packages/graphql-language-service-server/CHANGELOG.md index 91a4ddaeba0..39db56e2790 100644 --- a/packages/graphql-language-service-server/CHANGELOG.md +++ b/packages/graphql-language-service-server/CHANGELOG.md @@ -1,5 +1,18 @@ # graphql-language-service-server +## 2.14.0 + +### Minor Changes + +- [#3682](https://github.com/graphql/graphiql/pull/3682) [`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931) Thanks [@yaacovCR](https://github.com/yaacovCR)! - Support v17 of `graphql-js` from `17.0.0-alpha.2` forward. + + Includes support for the latest incremental delivery response format. For further details, see https://github.com/graphql/defer-stream-wg/discussions/69. + +### Patch Changes + +- Updated dependencies [[`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931)]: + - graphql-language-service@5.3.0 + ## 2.13.3 ### Patch Changes diff --git a/packages/graphql-language-service-server/package.json b/packages/graphql-language-service-server/package.json index a87186adf62..868dd3240be 100644 --- a/packages/graphql-language-service-server/package.json +++ b/packages/graphql-language-service-server/package.json @@ -1,6 +1,6 @@ { "name": "graphql-language-service-server", - "version": "2.13.3", + "version": "2.14.0", "description": "Server process backing the GraphQL Language Service", "contributors": [ "Greg Hurrell (https://greg.hurrell.net/)", @@ -34,7 +34,7 @@ "module": "esm/index.js", "typings": "esm/index.d.ts", "peerDependencies": { - "graphql": "^15.5.0 || ^16.0.0" + "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0-alpha.2" }, "COMMENT": "please do not remove dependencies without thorough testing. many dependencies are not imported directly, as they are peer dependencies", "dependencies": { @@ -47,7 +47,7 @@ "fast-glob": "^3.2.7", "glob": "^7.2.0", "graphql-config": "5.0.3", - "graphql-language-service": "^5.2.2", + "graphql-language-service": "^5.3.0", "lru-cache": "^10.2.0", "mkdirp": "^1.0.4", "node-abort-controller": "^3.0.1", @@ -68,7 +68,7 @@ "@types/mock-fs": "^4.13.4", "cross-env": "^7.0.2", "debounce-promise": "^3.1.2", - "graphql": "^16.9.0", + "graphql": "^17.0.0-alpha.5", "mock-fs": "^5.2.0" } } diff --git a/packages/graphql-language-service-server/src/__tests__/MessageProcessor.spec.ts b/packages/graphql-language-service-server/src/__tests__/MessageProcessor.spec.ts index fe50b3c071c..7e6695b1aac 100644 --- a/packages/graphql-language-service-server/src/__tests__/MessageProcessor.spec.ts +++ b/packages/graphql-language-service-server/src/__tests__/MessageProcessor.spec.ts @@ -11,6 +11,7 @@ import { buildASTSchema, introspectionFromSchema, parse, + version, } from 'graphql'; import fetchMock from 'fetch-mock'; import { schema as graphiqlSchema } from '../../../graphiql/test/schema'; @@ -361,6 +362,7 @@ describe('MessageProcessor with config', () => { }); it('caches files and schema with a URL config', async () => { + const offset = parseInt(version, 10) > 16 ? 25 : 0; mockSchema(graphiqlSchema); const project = new MockProject({ @@ -428,29 +430,29 @@ describe('MessageProcessor with config', () => { expect(serializeRange(typeDefinitions[0].range)).toEqual({ start: { - line: 11, + line: 11 + offset, character: 0, }, end: { - line: 102, + line: 102 + offset, character: 1, }, }); const schemaDefs = await project.lsp.handleDefinitionRequest({ textDocument: { uri: URI.parse(genSchemaPath).toString() }, - position: { character: 20, line: 18 }, + position: { character: 20, line: 18 + offset }, }); expect(schemaDefs[0].uri).toEqual(URI.parse(genSchemaPath).toString()); // note: if the graphiql test schema changes, // this might break, please adjust if you see a failure here expect(serializeRange(schemaDefs[0].range)).toEqual({ start: { - line: 104, + line: 104 + offset, character: 0, }, end: { - line: 112, + line: 112 + offset, character: 1, }, }); diff --git a/packages/graphql-language-service/CHANGELOG.md b/packages/graphql-language-service/CHANGELOG.md index 8bb6d733cfd..cb388248f1a 100644 --- a/packages/graphql-language-service/CHANGELOG.md +++ b/packages/graphql-language-service/CHANGELOG.md @@ -1,5 +1,13 @@ # graphql-language-service +## 5.3.0 + +### Minor Changes + +- [#3682](https://github.com/graphql/graphiql/pull/3682) [`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931) Thanks [@yaacovCR](https://github.com/yaacovCR)! - Support v17 of `graphql-js` from `17.0.0-alpha.2` forward. + + Includes support for the latest incremental delivery response format. For further details, see https://github.com/graphql/defer-stream-wg/discussions/69. + ## 5.2.2 ### Patch Changes diff --git a/packages/graphql-language-service/package.json b/packages/graphql-language-service/package.json index 193d4ea226b..5a3335c708f 100644 --- a/packages/graphql-language-service/package.json +++ b/packages/graphql-language-service/package.json @@ -1,6 +1,6 @@ { "name": "graphql-language-service", - "version": "5.2.2", + "version": "5.3.0", "description": "The official, runtime independent Language Service for GraphQL", "contributors": [ "GraphQL Contributors" @@ -32,7 +32,7 @@ "graphql": "./dist/temp-bin.js" }, "peerDependencies": { - "graphql": "^15.5.0 || ^16.0.0" + "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0-alpha.2" }, "dependencies": { "debounce-promise": "^3.1.2", @@ -45,7 +45,7 @@ "@types/json-schema": "7.0.9", "@types/picomatch": "^2.3.0", "benchmark": "^2.1.4", - "graphql": "^16.9.0", + "graphql": "^17.0.0-alpha.5", "graphql-config": "5.0.3", "lodash": "^4.17.15", "platform": "^1.3.5", diff --git a/packages/graphql-language-service/src/interface/__tests__/getDiagnostics-test.ts b/packages/graphql-language-service/src/interface/__tests__/getDiagnostics-test.ts index 85ce2fe7171..ccb2bc71311 100644 --- a/packages/graphql-language-service/src/interface/__tests__/getDiagnostics-test.ts +++ b/packages/graphql-language-service/src/interface/__tests__/getDiagnostics-test.ts @@ -17,6 +17,7 @@ import { ValidationContext, ASTVisitor, FragmentDefinitionNode, + version, } from 'graphql'; import path from 'node:path'; @@ -87,7 +88,13 @@ describe('getDiagnostics', () => { for (const definition of node.definitions) { // add a custom error to every definition validationContext.reportError( - new GraphQLError('This is a custom error.', definition), + new GraphQLError( + 'This is a custom error.', + // @ts-expect-error + parseInt(version, 10) > 16 + ? { nodes: definition } + : definition, + ), ); } return false; @@ -158,7 +165,13 @@ describe('getDiagnostics', () => { const noQueryRule = (context: ValidationContext): ASTVisitor => ({ OperationDefinition(node) { if (node.operation === 'query') { - context.reportError(new GraphQLError('No query allowed.', node.name)); + context.reportError( + new GraphQLError( + 'No query allowed.', + // @ts-expect-error + parseInt(version, 10) > 16 ? { nodes: node } : node, + ), + ); } }, }); diff --git a/packages/graphql-language-service/src/utils/__tests__/validateWithCustomRules-test.ts b/packages/graphql-language-service/src/utils/__tests__/validateWithCustomRules-test.ts index 6ba7de8002b..b65c35c1eab 100644 --- a/packages/graphql-language-service/src/utils/__tests__/validateWithCustomRules-test.ts +++ b/packages/graphql-language-service/src/utils/__tests__/validateWithCustomRules-test.ts @@ -14,6 +14,7 @@ import { GraphQLSchema, ValidationContext, ArgumentNode, + version, } from 'graphql'; import { join } from 'node:path'; @@ -37,7 +38,8 @@ describe('validateWithCustomRules', () => { context.reportError( new GraphQLError( 'Argument ID must be a number written in string type.', - [node], + // @ts-expect-error + parseInt(version, 10) > 16 ? { nodes: node } : node, ), ); } diff --git a/packages/monaco-graphql/CHANGELOG.md b/packages/monaco-graphql/CHANGELOG.md index 3598596e396..b054831a995 100644 --- a/packages/monaco-graphql/CHANGELOG.md +++ b/packages/monaco-graphql/CHANGELOG.md @@ -1,5 +1,18 @@ # Change Log +## 1.6.0 + +### Minor Changes + +- [#3682](https://github.com/graphql/graphiql/pull/3682) [`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931) Thanks [@yaacovCR](https://github.com/yaacovCR)! - Support v17 of `graphql-js` from `17.0.0-alpha.2` forward. + + Includes support for the latest incremental delivery response format. For further details, see https://github.com/graphql/defer-stream-wg/discussions/69. + +### Patch Changes + +- Updated dependencies [[`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931)]: + - graphql-language-service@5.3.0 + ## 1.5.3 ### Patch Changes diff --git a/packages/monaco-graphql/package.json b/packages/monaco-graphql/package.json index 15b7e2bcc8b..14dc88a1a2e 100644 --- a/packages/monaco-graphql/package.json +++ b/packages/monaco-graphql/package.json @@ -1,7 +1,7 @@ { "name": "monaco-graphql", "description": "full service, official monaco mode for GraphQL", - "version": "1.5.3", + "version": "1.6.0", "license": "MIT", "main": "dist/monaco.contribution.js", "module": "esm/monaco.contribution.js", @@ -66,18 +66,18 @@ "test": "vitest run" }, "dependencies": { - "graphql-language-service": "^5.2.2", + "graphql-language-service": "^5.3.0", "picomatch-browser": "^2.2.6" }, "devDependencies": { "execa": "^7.1.1", - "graphql": "^16.9.0", + "graphql": "^17.0.0-alpha.5", "monaco-editor": "^0.39.0", "prettier": "3.3.2", "vscode-languageserver-types": "^3.17.1" }, "peerDependencies": { - "graphql": "^15.5.0 || ^16.0.0", + "graphql": "^15.5.0 || ^16.0.0 || ^17.0.0-alpha.2", "monaco-editor": ">= 0.20.0 < 1", "prettier": "^2.8.0 || ^3.0.0" } diff --git a/packages/monaco-graphql/test/monaco-editor.test.ts b/packages/monaco-graphql/test/monaco-editor.test.ts index d1a566717a9..fee02855f48 100644 --- a/packages/monaco-graphql/test/monaco-editor.test.ts +++ b/packages/monaco-graphql/test/monaco-editor.test.ts @@ -1,4 +1,5 @@ import { $ } from 'execa'; +import { version } from 'graphql'; // eslint-disable-next-line no-control-regex const ANSI_COLOR_REGEX = /\u001b\[\d+m/g; @@ -13,7 +14,9 @@ describe('monaco-editor', () => { // expect(lines[0]).toBe('$ vite build'); // expect(lines[1]).toMatch(' building for production...'); // expect(lines[2]).toBe('transforming...'); - expect(lines[3]).toMatch('✓ 844 modules transformed.'); + expect(lines[3]).toMatch( + `✓ ${parseInt(version, 10) > 16 ? 856 : 843} modules transformed.`, + ); // expect(lines[4]).toBe('rendering chunks...'); // expect(lines[5]).toBe('computing gzip size...'); // expect(lines[6]).toMatch('dist/index.html'); diff --git a/packages/vscode-graphql-execution/CHANGELOG.md b/packages/vscode-graphql-execution/CHANGELOG.md index f8e72dbc41d..73dfa6119e3 100644 --- a/packages/vscode-graphql-execution/CHANGELOG.md +++ b/packages/vscode-graphql-execution/CHANGELOG.md @@ -1,5 +1,13 @@ # vscode-graphql-execution +## 0.3.0 + +### Minor Changes + +- [#3682](https://github.com/graphql/graphiql/pull/3682) [`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931) Thanks [@yaacovCR](https://github.com/yaacovCR)! - Support v17 of `graphql-js` from `17.0.0-alpha.2` forward. + + Includes support for the latest incremental delivery response format. For further details, see https://github.com/graphql/defer-stream-wg/discussions/69. + ## 0.2.6 ### Patch Changes diff --git a/packages/vscode-graphql-execution/package.json b/packages/vscode-graphql-execution/package.json index c7af7629bba..6cb04f08616 100644 --- a/packages/vscode-graphql-execution/package.json +++ b/packages/vscode-graphql-execution/package.json @@ -1,6 +1,6 @@ { "name": "vscode-graphql-execution", - "version": "0.2.6", + "version": "0.3.0", "displayName": "GraphQL: Inline Operation Execution", "description": "Execute graphql operations from your code (revived!)", "publisher": "GraphQL", @@ -109,7 +109,7 @@ "cosmiconfig": "8.2.0", "cosmiconfig-toml-loader": "^1.0.0", "dotenv": "10.0.0", - "graphql": "^16.9.0", + "graphql": "^16.9.0 || ^17.0.0-alpha.2", "graphql-config": "5.0.3", "graphql-tag": "2.12.6", "graphql-ws": "5.10.0", diff --git a/packages/vscode-graphql/CHANGELOG.md b/packages/vscode-graphql/CHANGELOG.md index 7f5b8366d54..8466274207a 100644 --- a/packages/vscode-graphql/CHANGELOG.md +++ b/packages/vscode-graphql/CHANGELOG.md @@ -1,5 +1,18 @@ # Change Log +## 0.12.0 + +### Minor Changes + +- [#3682](https://github.com/graphql/graphiql/pull/3682) [`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931) Thanks [@yaacovCR](https://github.com/yaacovCR)! - Support v17 of `graphql-js` from `17.0.0-alpha.2` forward. + + Includes support for the latest incremental delivery response format. For further details, see https://github.com/graphql/defer-stream-wg/discussions/69. + +### Patch Changes + +- Updated dependencies [[`6c9f0df`](https://github.com/graphql/graphiql/commit/6c9f0df83ea4afe7fa59f84d83d59fba73dc3931)]: + - graphql-language-service-server@2.14.0 + ## 0.11.3 ### Patch Changes diff --git a/packages/vscode-graphql/package.json b/packages/vscode-graphql/package.json index 35b17d5cb97..50d0f059553 100644 --- a/packages/vscode-graphql/package.json +++ b/packages/vscode-graphql/package.json @@ -1,6 +1,6 @@ { "name": "vscode-graphql", - "version": "0.11.3", + "version": "0.12.0", "private": true, "license": "MIT", "displayName": "GraphQL: Language Feature Support", @@ -179,8 +179,8 @@ "ovsx": "0.8.3" }, "dependencies": { - "graphql": "^16.9.0", - "graphql-language-service-server": "^2.13.3", + "graphql": "^16.9.0 || ^17.0.0-alpha.2", + "graphql-language-service-server": "^2.14.0", "vscode-languageclient": "8.0.2", "typescript": "^5.3.3" } diff --git a/resources/patches/graphql+17.0.0-alpha.5.patch b/resources/patches/graphql+17.0.0-alpha.5.patch new file mode 100644 index 00000000000..82e4f39cf16 --- /dev/null +++ b/resources/patches/graphql+17.0.0-alpha.5.patch @@ -0,0 +1,26 @@ +diff --git a/node_modules/graphql/execution/execute.js b/node_modules/graphql/execution/execute.js +index eb56e4b..5a4a398 100644 +--- a/node_modules/graphql/execution/execute.js ++++ b/node_modules/graphql/execution/execute.js +@@ -2055,7 +2055,7 @@ async function getNextAsyncStreamItemResult( + getNextAsyncStreamItemResult( + streamItemQueue, + streamPath, +- index, ++ index + 1, + asyncIterator, + exeContext, + fieldGroup, +diff --git a/node_modules/graphql/execution/execute.mjs b/node_modules/graphql/execution/execute.mjs +index 641c067..c7641d4 100644 +--- a/node_modules/graphql/execution/execute.mjs ++++ b/node_modules/graphql/execution/execute.mjs +@@ -1984,7 +1984,7 @@ async function getNextAsyncStreamItemResult( + getNextAsyncStreamItemResult( + streamItemQueue, + streamPath, +- index, ++ index + 1, + asyncIterator, + exeContext, + fieldGroup, diff --git a/yarn.lock b/yarn.lock index 68bc66ccbb3..bc64ce8c792 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4092,6 +4092,11 @@ resolved "https://registry.yarnpkg.com/@types/fetch-mock/-/fetch-mock-7.3.2.tgz#58805ba36a9357be92cc8c008dbfda937e9f7d8f" integrity sha512-NCEfv49jmDsBAixjMjEHKVgmVQlJ+uK56FOc+2roYPExnXCZDpi6mJOHQ3v23BiO84hBDStND9R2itJr7PNoow== +"@types/get-value@^3.0.5": + version "3.0.5" + resolved "https://registry.yarnpkg.com/@types/get-value/-/get-value-3.0.5.tgz#4ea0e0b0a31c256636b3e7e0026c2ad38baea6f6" + integrity sha512-+o8nw0TId5cDwtdVrhlc8rvzaxbCU+JksFeu8ZunY9vUaODxngXiNceTFj2gkSwGWNRpe3PtaSWt1y0VB71PvA== + "@types/glob@^8.1.0": version "8.1.0" resolved "https://registry.yarnpkg.com/@types/glob/-/glob-8.1.0.tgz#b63e70155391b0584dce44e7ea25190bbc38f2fc" @@ -6405,9 +6410,9 @@ caniuse-lite@^1.0.30001640: integrity sha512-ERgWGNleEilSrHM6iUz/zJNSQTP8Mr21wDWpdgvRwcTXGAq6jMtOUPP4dqFPTdKqZ2wKTdtB+uucZ3MRpAUSmg== caniuse-lite@^1.0.30001646: - version "1.0.30001650" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001650.tgz#dd1eba0938e39536d184c3c99b2569a13788bc16" - integrity sha512-fgEc7hP/LB7iicdXHUI9VsBsMZmUmlVJeQP2qqQW+3lkqVhbmjEU8zp+h5stWeilX+G7uXuIUIIlWlDw9jdt8g== + version "1.0.30001651" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz#52de59529e8b02b1aedcaaf5c05d9e23c0c28138" + integrity sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg== capital-case@^1.0.4: version "1.0.4" @@ -7886,9 +7891,9 @@ electron-to-chromium@^1.4.820: integrity sha512-FKbOCOQ5QRB3VlIbl1LZQefWIYwszlBloaXcY2rbfpu9ioJnNh3TK03YtIDKDo3WKBi8u+YV4+Fn2CkEozgf4w== electron-to-chromium@^1.5.4: - version "1.5.5" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.5.tgz#03bfdf422bdd2c05ee2657efedde21264a1a566b" - integrity sha512-QR7/A7ZkMS8tZuoftC/jfqNkZLQO779SSW3YuZHP4eXpj3EffGLFcB/Xu9AAZQzLccTiCV+EmUo3ha4mQ9wnlA== + version "1.5.6" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.6.tgz#c81d9938b5a877314ad370feb73b4e5409b36abd" + integrity sha512-jwXWsM5RPf6j9dPYzaorcBSUg6AiqocPEyMpkchkvntaH9HGfOOMZwxMJjDY/XEs3T5dM7uyH1VhRMkqUU9qVw== elegant-spinner@^1.0.1: version "1.0.1" @@ -9664,6 +9669,13 @@ get-tsconfig@^4.7.3: dependencies: resolve-pkg-maps "^1.0.0" +get-value@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/get-value/-/get-value-3.0.1.tgz#5efd2a157f1d6a516d7524e124ac52d0a39ef5a8" + integrity sha512-mKZj9JLQrwMBtj5wxi6MH8Z5eSKaERpAwjg43dPtlGI1ZVEgH/qC7T8/6R2OBSUA+zzHBZgICsVJaEIV2tKTDA== + dependencies: + isobject "^3.0.1" + getos@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/getos/-/getos-3.2.1.tgz#0134d1f4e00eb46144c5a9c0ac4dc087cbb27dc5" @@ -9909,10 +9921,15 @@ graphql-config@5.0.3: string-env-interpolation "^1.0.1" tslib "^2.4.0" -graphql-http@^1.19.0: - version "1.19.0" - resolved "https://registry.yarnpkg.com/graphql-http/-/graphql-http-1.19.0.tgz#6f0fff0dbd9a8e797c99b5ac0ca160566e7927da" - integrity sha512-fOD3hfp/G+Lhx2FWW5HsfmtJSsw6CikcpOboG7/mFo/pPUzn3yOwKdTFRnJ8MVY4ru69MT1nSPr/1gI/iuGNlw== +graphql-helix@^1.13.0: + version "1.13.0" + resolved "https://registry.yarnpkg.com/graphql-helix/-/graphql-helix-1.13.0.tgz#e64dad5ef5f622ef38c97fa033f56f3d953c0104" + integrity sha512-cqDKMoRywKjnL0ZWCTB0GOiBgsH6d3nU4JGDF6RuzAyd35tmalzKpSxkx3NNp4H5RvnKWnrukWzR51wUq277ng== + +graphql-http@^1.22.1: + version "1.22.1" + resolved "https://registry.yarnpkg.com/graphql-http/-/graphql-http-1.22.1.tgz#3857ac75366e55db189cfe09ade9cc4c4f2cfd09" + integrity sha512-4Jor+LRbA7SfSaw7dfDUs2UBzvWg3cKrykfHRgKsOIvQaLuf+QOcG2t3Mx5N9GzSNJcuqMqJWz0ta5+BryEmXg== graphql-subscriptions@^2.0.0: version "2.0.0" @@ -9938,10 +9955,10 @@ graphql-ws@5.14.0, graphql-ws@^5.5.5: resolved "https://registry.yarnpkg.com/graphql-ws/-/graphql-ws-5.14.0.tgz#766f249f3974fc2c48fae0d1fb20c2c4c79cd591" integrity sha512-itrUTQZP/TgswR4GSSYuwWUzrE/w5GhbwM2GX3ic2U7aw33jgEsayfIlvaj7/GcIvZgNMzsPTrE5hqPuFUiE5g== -graphql@^16.9.0: - version "16.9.0" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.9.0.tgz#1c310e63f16a49ce1fbb230bd0a000e99f6f115f" - integrity sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw== +graphql@17.0.0-alpha.5, graphql@^16.9.0, "graphql@^16.9.0 || ^17.0.0-alpha.2", graphql@^17.0.0-alpha.5: + version "17.0.0-alpha.5" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-17.0.0-alpha.5.tgz#d094b76c14abbbfc7eabde0501a74709103d3c6b" + integrity sha512-gUBugdZH5nIl8G7cfz4WOKRtjcyuwpPTfFqWWMkcxpQCiO6wPRe7OfrjHe7p8mHEFG1a+ySzC7eB8idGZ27AGQ== handle-thing@^2.0.0: version "2.0.1" @@ -13096,7 +13113,7 @@ mimic-response@^3.1.0: min-document@^2.19.0: version "2.19.0" resolved "https://registry.yarnpkg.com/min-document/-/min-document-2.19.0.tgz#7bd282e3f5842ed295bb748cdd9f1ffa2c824685" - integrity sha512-9Wy1B3m3f66bPPmU5hdA4DR4PB2OfDU/+GS3yAB7IQozE3tqXaVv2zOjgla7MEGSRv95+ILmOuvhLkOK6wJtCQ== + integrity sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU= dependencies: dom-walk "^0.1.0" @@ -14195,9 +14212,9 @@ postcss-import@15.1.0: resolve "^1.1.7" postcss-lightningcss@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/postcss-lightningcss/-/postcss-lightningcss-1.0.0.tgz#a755fd04d5a20f2673afb15afe317a6563ddb8c1" - integrity sha512-sLNRVh+DINZHf5b31KUZnv3w4sf/CEdmvYP5JWzyyB8++E6WdaE7yxsrhfXiUFqISNBXcSrKfAF/MtTZrYAlbg== + version "1.0.1" + resolved "https://registry.yarnpkg.com/postcss-lightningcss/-/postcss-lightningcss-1.0.1.tgz#4a28c451e5205e0da6ec9110ad881f8d6b1b222f" + integrity sha512-9IrtZVt2HQ92iZJTkO43Qipx7E3PM+lLzZM8aGwMmMjNQHcir5jNC42U33p3Gh2lj1nES/ireYWEbMrJNiRBoQ== dependencies: browserslist "^4.19.1" lightningcss "^1.22.0" @@ -17227,9 +17244,9 @@ vite-plugin-commonjs@^0.10.1: vite-plugin-dynamic-import "^1.5.0" vite-plugin-dts@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/vite-plugin-dts/-/vite-plugin-dts-4.0.1.tgz#4a4dedc373292930a737879a8a35cb83f73af071" - integrity sha512-JFbAKMjJdJbeXJVwQNoi8M26lP+5Ene4/ryv9w0Z7Ca5N0DdxYEak9V3C0tqwHO7WZ9JLbwMsuUZOqYIyBRwSQ== + version "4.0.2" + resolved "https://registry.yarnpkg.com/vite-plugin-dts/-/vite-plugin-dts-4.0.2.tgz#efe6367decbb2eb851e12ec0707d2459f6d5d0b8" + integrity sha512-Ni3EPG8yeLc5ivEzT4szreJ0rXpEQgvdYq3PaZ7OMoHc8uET4/HRUfzVPejJaUAojbxsKgaZbp6Zgm41sxb86Q== dependencies: "@microsoft/api-extractor" "7.47.4" "@rollup/pluginutils" "^5.1.0"