Skip to content

Commit 1c11938

Browse files
committed
feat: defer, stream, websockets support in a createGraphiQLFetcher utility (#1770)
- support for `@defer` and `@stream` in `GraphiQL` itself on fetcher execution and when handling stream payloads - introduce `@graphiql/toolkit` for types and utilities used to compose `GraphiQL` and other related libraries - introduce `@graphiql/create-fetcher` to accept simplified parameters to generate a `fetcher` that covers the most commonly used `graphql-over-http` transport spec proposals. using `meros` for multipart http, and `graphql-ws` for websockets subscriptions. - use `graphql` and `graphql-express` `experimental-defer-stream` branch in development until it's merged - add cypress e2e tests for `@stream` in different scenarios - add some unit tests for `createGraphiQLFetcher` - add `changesets` because lerna publish no longer works. get rid of commitlint
1 parent 881d8b5 commit 1c11938

File tree

68 files changed

+2475
-3357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2475
-3357
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/master/docs/common-questions.md)

.changeset/config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"linked": [],
6+
"access": "public",
7+
"baseBranch": "main",
8+
"updateInternalDependencies": "minor",
9+
"ignore": ["example-*", "graphiql-2-rfc-context*"]
10+
}

.changeset/early-stingrays-pay.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'graphiql': minor
3+
'@graphiql/create-fetcher': minor
4+
'@graphiql/toolkit': minor
5+
---
6+
7+
`@defer`, `@stream`, and `graphql-ws` support in a `createGraphiQLFetcher` utility (#1770)
8+
9+
- support for `@defer` and `@stream` in `GraphiQL` itself on fetcher execution and when handling stream payloads
10+
- introduce `@graphiql/toolkit` for types and utilities used to compose `GraphiQL` and other related libraries
11+
- introduce `@graphiql/create-fetcher` to accept simplified parameters to generate a `fetcher` that covers the most commonly used `graphql-over-http` transport spec proposals. using `meros` for multipart http, and `graphql-ws` for websockets subscriptions.
12+
- use `graphql` and `graphql-express` `experimental-defer-stream` branch in development until it's merged
13+
- add cypress e2e tests for `@stream` in different scenarios
14+
- add some unit tests for `createGraphiQLFetcher`

.eslintrc.js

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module.exports = {
3030
node: true,
3131
browser: true,
3232
jest: true,
33+
'jest/globals': true,
3334
},
3435

3536
extends: [
@@ -294,6 +295,9 @@ module.exports = {
294295
'react/prefer-stateless-function': 'error',
295296
'react/react-in-jsx-scope': 'error',
296297
'react/self-closing-comp': 'error',
298+
'react/display-name': 'warn',
299+
// Jest rules
300+
'jest/no-conditional-expect': 0,
297301
},
298302

299303
plugins: ['import', 'prefer-object-spread', '@typescript-eslint'],
@@ -310,14 +314,18 @@ module.exports = {
310314
},
311315
},
312316
{
317+
excludedFiles: ['**/cypress/**/*.{js,ts}'],
313318
files: [
314-
'packages/{*graphql-*,graphiql}/src/**',
315319
'**/__{tests,mocks}__/*.{js,jsx,ts,tsx}',
320+
'**/*.spec.{ts,js.jsx.tsx}',
316321
],
317322
extends: ['plugin:jest/recommended'],
318323
env: {
319324
'jest/globals': true,
320325
},
326+
rules: {
327+
'jest/no-conditional-expect': 0,
328+
},
321329
},
322330
// Rules for TypeScript only
323331
{
@@ -326,28 +334,6 @@ module.exports = {
326334
'no-unused-vars': 'off',
327335
},
328336
},
329-
// Rules for Babel & Flow only
330-
{
331-
files: ['packages/codemirror-graphql/src/**/*.js'],
332-
parser: 'babel-eslint',
333-
plugins: ['flowtype', 'babel'],
334-
rules: {
335-
// flowtype (https://github.com/gajus/eslint-plugin-flowtype)
336-
'flowtype/boolean-style': 1,
337-
'flowtype/define-flow-type': 1,
338-
'flowtype/no-dupe-keys': 0,
339-
'flowtype/no-primitive-constructor-types': 1,
340-
'flowtype/no-weak-types': 0,
341-
'flowtype/require-parameter-type': 0,
342-
'flowtype/require-return-type': 0,
343-
'flowtype/require-valid-file-annotation': 0,
344-
'flowtype/require-variable-type': 0,
345-
'flowtype/sort-keys': 0,
346-
'flowtype/type-id-match': 0,
347-
'flowtype/use-flow-type': 1,
348-
'flowtype/valid-syntax': 0,
349-
},
350-
},
351337
{
352338
// Converted from 'dependencies' options in ancient config
353339
files: ['**/spec/**', '**/sample-*/**'],

.github/workflows/fork.yml.archived

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/issue.yml.archived

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
jobs:
8+
release:
9+
name: Release
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Repo
13+
uses: actions/checkout@master
14+
with:
15+
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
16+
fetch-depth: 0
17+
- name: Setup Node.js 12.x
18+
uses: actions/setup-node@master
19+
with:
20+
node-version: 12.x
21+
- uses: bahmutov/npm-install@v1
22+
- name: Create Release Pull Request or Publish to npm
23+
id: changesets
24+
uses: changesets/action@master
25+
with:
26+
# This expects you to have a script called release which does a build for your packages and calls changeset publish
27+
publish: yarn release
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/review-submitted.yml.archived

Lines changed: 0 additions & 15 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ lerna-debug.log
2626
.yarnrc
2727
yarn-1.18.0.js
2828
*.orig
29+
30+
# Local Netlify folder
31+
.netlify

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
engine-strict=true
2+
access=public

RELEASING.md

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,3 @@
11
# Cutting New Releases
22

3-
We chose a manual process which is pretty simple and flexible because of our conventional commit messages.
4-
5-
If you have NPM privileges, you have the ability to cut new releases of the packages herein.
6-
7-
## Requirements
8-
9-
You'll need:
10-
11-
- `GH_TOKEN` : a github user token as an environment variable
12-
- `git` command line installed, obviously!
13-
- to run `yarn login` first to ensure you're authenticated for publishing
14-
- your npm 2FA should be enabled, and you should have your second factor device handy for publish
15-
- your remote should be named `origin` for github, and should be the ssh url
16-
- (coming soon) GPG key uploaded to account for signing
17-
18-
Note: Always publish from `master`. Always execute `yarn test` beforehand, and check the `examples/graphiql-webpack` to ensure there aren't any webpack build bugs.
19-
20-
## Prereleases
21-
22-
```sh
23-
lerna publish --conventional-prerelease graphiql --otp <your-otp>
24-
```
25-
26-
for a specific package, or leave blank for all packages.
27-
28-
It will automatically generate pre-release versions that reflect the conventional pattern from the commit log - so some packages may end up pre-alpha, others may be pre-minor, etc.
29-
30-
For example, if you made a change to `graphql-language-service-utils` there would be a new version for every single package. But if you made a change to `graphiql` in the commits since the last publish, there should only be a new pre-release version for `graphiql` when you run this command.
31-
32-
You can also `--amend` a previous release upon publishing, overriding the previous git tags
33-
34-
## Graduating Prereleases
35-
36-
Now, after creating and publishing some pre-release versions, if you want to graduate them you can do so with a command that works in very much the same way as above.
37-
38-
```sh
39-
lerna publish --conventional-graduate * --otp <your token>
40-
```
41-
42-
Would graduate all pre-alphas to patch releases, pre-minors to minor releases, etc.
43-
44-
You can also give a comma seperated list of packages, or just a single one, as with `prereleases`
45-
46-
```sh
47-
lerna publish --conventional-graduate codemirror-graphql --otp <your token>
48-
```
49-
50-
## Full Releases
51-
52-
```sh
53-
lerna publish --otp <your token>
54-
```
55-
56-
Will automatically detect and generate changelog/etc with appropriate versions and entries for all subpackage, no need to supply package names or an asterisk
3+
TODO: Redo for `changesets`. See [`Changesets Readme`](./.changeset/README.md)

commitlint.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/graphiql-create-react-app/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
"version": "0.1.11-alpha.8",
44
"private": true,
55
"dependencies": {
6-
"@types/react": "^16.9.34",
7-
"@types/react-dom": "^16.9.6",
86
"graphiql": "file:../../packages/graphiql",
9-
"graphql": "^15.0.0",
7+
"graphql": "experimental-stream-defer",
108
"react": "^16.13.1",
119
"react-dom": "^16.13.1",
1210
"react-scripts": "3.4.1"

examples/graphiql-parcel/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "graphiql-parcel-example",
2+
"name": "example-graphiql-parcel",
33
"version": "1.1.10-alpha.8",
44
"license": "MIT",
55
"description": "GraphiQL Parcel Example",
@@ -22,10 +22,8 @@
2222
]
2323
},
2424
"dependencies": {
25-
"@types/react": "^16.9.34",
26-
"@types/react-dom": "^16.9.6",
2725
"graphiql": "file:../../packages/graphiql",
28-
"graphql": "15.0.0",
26+
"graphql": "experimental-stream-defer",
2927
"react": "^16.13.1",
3028
"react-dom": "^16.13.1",
3129
"typescript": "^3.4.4"

examples/graphiql-webpack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"graphiql": "file:../../packages/graphiql",
14-
"graphql": "15.0.0",
14+
"graphql": "experimental-stream-defer",
1515
"react": "16.13.1"
1616
},
1717
"devDependencies": {

examples/monaco-graphql-webpack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"start": "cross-env NODE_ENV=development webpack-dev-server"
1212
},
1313
"dependencies": {
14-
"graphql": "14.6.0",
14+
"graphql": "experimental-stream-defer",
1515
"monaco-graphql": "file:../../packages/monaco-graphql",
1616
"prettier": "^2.0.2"
1717
},

functions/schema-demo.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* example using https://github.com/awslabs/aws-serverless-express */
2+
const express = require('express');
3+
const { graphqlHTTP } = require('express-graphql');
4+
const awsServerlessExpress = require('aws-serverless-express');
5+
const schema = require('../packages/graphiql/test/schema');
6+
const cors = require('cors');
7+
8+
const binaryMimeTypes = [
9+
'application/javascript',
10+
'application/json',
11+
'font/eot',
12+
'font/opentype',
13+
'font/otf',
14+
'image/jpeg',
15+
'image/png',
16+
'image/svg+xml',
17+
'text/css',
18+
'text/html',
19+
'text/javascript',
20+
'multipart/mixed',
21+
];
22+
23+
const app = express();
24+
25+
app.use(cors({ origin: '*' }));
26+
27+
// Requests to /graphql redirect to /
28+
app.all('/graphql', (req, res) => res.redirect('/'));
29+
30+
// Finally, serve up the GraphQL Schema itself
31+
app.use(
32+
'/',
33+
graphqlHTTP(() => ({ schema })),
34+
);
35+
36+
const server = awsServerlessExpress.createServer(app, null, binaryMimeTypes);
37+
38+
exports.handler = (event, context) =>
39+
awsServerlessExpress.proxy(server, event, context);
40+
41+
// // Server
42+
// app.post('/graphql', graphqlHTTP({ schema }));
43+
44+
// // app.get('/graphql', graphQLMiddleware);
45+
// // Export Lambda handler
46+
47+
// exports.handler = serverless(app, {
48+
// httpMethod: 'POST'
49+
// })

lerna.json

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)