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

V3 #1487

Merged
merged 61 commits into from
Oct 12, 2022
Merged

V3 #1487

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
726519d
feat: non-breaking GraphQL Engine
saihaj Aug 17, 2022
a84ea46
feat: make envelop take in engine functions
saihaj Aug 22, 2022
5320ae5
structural typings
saihaj Aug 22, 2022
871208e
remove grapqhl as peer dep from types pkg
saihaj Aug 22, 2022
732ec5e
make core more agnostic
saihaj Aug 22, 2022
4d09e1d
chore(dependencies): updated changesets for modified dependencies
github-actions[bot] Aug 22, 2022
4f6fe63
remove traced schema
saihaj Aug 23, 2022
dd616a1
remove traced orchestrator
saihaj Aug 23, 2022
1244549
make plugin agnostic
saihaj Aug 23, 2022
28bfd92
drop EnvelopError
saihaj Aug 23, 2022
6ba3999
remove more graphql import
saihaj Aug 23, 2022
ae21a6e
Drop useTiming
saihaj Aug 23, 2022
da7c81c
make core completely free of graphql-js
saihaj Aug 23, 2022
5010b96
add eslint rule
saihaj Aug 23, 2022
2f8c24b
eslint disallow in types too
saihaj Aug 23, 2022
d55b626
more agnostic packages
saihaj Aug 23, 2022
184db16
remove introspection util
saihaj Aug 24, 2022
06687c4
Merge branch 'main' into saihaj/engine-agnostic-non-breaking
saihaj Aug 24, 2022
6964702
chore(dependencies): updated changesets for modified dependencies
github-actions[bot] Aug 24, 2022
6ec5792
prettier
saihaj Aug 24, 2022
680dbda
TEMP: make bot calm down
saihaj Aug 24, 2022
f0373e1
update all docs
saihaj Aug 24, 2022
d8be662
test matrix for core
saihaj Aug 24, 2022
c1274cd
experimenting traced schema (#1501)
saihaj Aug 31, 2022
2647f7f
feat: drop node 12 (#1505)
saihaj Sep 1, 2022
3442989
Merge branch 'main' into saihaj/engine-agnostic-non-breaking
saihaj Sep 1, 2022
5ab6cc6
feat: remove `enableIf` utility (#1504)
saihaj Sep 2, 2022
6e27fdd
feat: remove async schema plugin and rename lazy loaded schema plugin…
saihaj Sep 5, 2022
59d8a78
add eslint rule (#1509)
saihaj Sep 7, 2022
49cf420
feat: `@envelop/on-resolve` plugin for hooking into schema resolvers …
enisdenjo Sep 7, 2022
050d317
docs: order of plugins matter (#1513)
saihaj Sep 7, 2022
b1bf2e9
feat: remove handler for validation and parse errors (#1510)
saihaj Sep 8, 2022
7b7b530
add changeset
saihaj Sep 12, 2022
593b119
Merge branch 'main' into saihaj/engine-agnostic-non-breaking
saihaj Sep 12, 2022
cdbfbb2
Update .changeset/nervous-seas-own.md
saihaj Sep 12, 2022
ebf9e1a
Update .changeset/rude-cats-peel.md
saihaj Sep 12, 2022
7bc6412
no-use-before-define (#1522)
enisdenjo Sep 13, 2022
1770063
feat: trigger on context, validate and parse errors (#1511)
saihaj Sep 13, 2022
9399a33
docs: migration guide (#1520)
saihaj Sep 15, 2022
1720176
Add redirects
saihaj Sep 15, 2022
049f13d
remove deafult skip error from sentry plugin
saihaj Sep 15, 2022
43adce7
export masked error plugin
saihaj Sep 15, 2022
1b063e9
sentry plugin default skip GraphQLError
saihaj Sep 15, 2022
6cbf555
sentry: og error is not graphql error then send to sentry
saihaj Sep 16, 2022
36b3d28
doc: drop introspection utils
saihaj Sep 20, 2022
af08536
should fix ts issues on v15
saihaj Sep 20, 2022
fbef7dd
test: stack error we should not match the error name since it can be …
saihaj Sep 21, 2022
b32fda2
feat: use engine plugin (#1535)
saihaj Sep 28, 2022
5805d5a
Merge branch 'main' into saihaj/engine-agnostic-non-breaking
saihaj Sep 28, 2022
af295b0
Merge branch 'main' into saihaj/engine-agnostic-non-breaking
saihaj Oct 10, 2022
ce3728a
fix
saihaj Oct 10, 2022
32d6c10
versioned docs with v3 default
saihaj Oct 10, 2022
a7819c6
fix build
saihaj Oct 10, 2022
f2afa3b
fix
saihaj Oct 10, 2022
748132d
feat this is cool
saihaj Oct 11, 2022
a0bbe32
docs reword schema tracing
saihaj Oct 11, 2022
27375db
docs add graphql error example
saihaj Oct 11, 2022
4851db7
docs restructuring, fix typos
saihaj Oct 11, 2022
5bdc22a
chore remove autogenerated changeset
saihaj Oct 11, 2022
5eba9aa
cleanup changeset
saihaj Oct 11, 2022
78febf3
docs sycn patch
saihaj Oct 11, 2022
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
5 changes: 5 additions & 0 deletions .changeset/bright-fishes-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@envelop/core': major
---

## Remove `isIntrospectionQuery` utility
5 changes: 5 additions & 0 deletions .changeset/curvy-bottles-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@envelop/core': major
---

Remove async schema loading plugin. This was a mistake from beginning as we cannot asynchronously `validate` and `parse` since with GraphQL.js are synchronous in nature.
33 changes: 33 additions & 0 deletions .changeset/curvy-cheetahs-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
'@envelop/core': major
'@envelop/on-resolve': major
---

## Remove `onResolverCalled`

We decided to drop onResolverCalled hook and instead [provide a new plugin](https://github.com/n1ru4l/envelop/pull/1500) that will let you hook into this phase.

```diff
import { parse, validate, execute, subscribe } from 'graphql'
import { envelop, Plugin, useEngine } from '@envelop/core'
+ import { useOnResolve } from '@envelop/on-resolve'

import { onResolverCalled } from './my-resolver'

function useResolve(): Plugin {
return {
- onResolverCalled: onResolverCalled,
+ onPluginInit: ({ addPlugin }) => {
+ addPlugin(useOnResolve(onResolverCalled))
+ },
}
}

const getEnveloped = envelop({
plugins: [
useEngine({ parse, validate, execute, subscribe }),
// ... other plugins ...
useResolve(),
],
});
```
5 changes: 5 additions & 0 deletions .changeset/dirty-birds-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@envelop/sentry': major
---

Default skip reporting `GraphQLError`
7 changes: 7 additions & 0 deletions .changeset/dry-donuts-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@envelop/core': major
---

## Drop `useTiming` plugin

This plugin was dependent on tracing the schema. As we no longer support wrap the schema out of the box we decided to drop this plugin.
5 changes: 5 additions & 0 deletions .changeset/grumpy-windows-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@envelop/core': major
---

## Remove `isIntrospectionDocument` utility
7 changes: 7 additions & 0 deletions .changeset/late-students-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@envelop/core': major
---

## Drop Node v12 support

Node.js v12 is no longer supported by the Node.js team. https://github.com/nodejs/Release/#end-of-life-releases
7 changes: 7 additions & 0 deletions .changeset/light-bees-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@envelop/core': major
---

## Drop `EnvelopError` class

To keep the core agnostic from a specific implementation we no longer provide the `EnvelopError` class.
7 changes: 7 additions & 0 deletions .changeset/light-tomatoes-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@envelop/core': major
---

## Remove `useAsyncSchema` plugin

This was a mistake from beginning as we cannot asynchronously validate and parse since with [graphql](https://github.com/graphql/graphql-js) these functions are synchronous in nature.
19 changes: 19 additions & 0 deletions .changeset/lovely-clocks-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'@envelop/core': major
---

## Remove `graphql` as a peer dependency

We have built the new `envelop` to be engine agnostic. `graphql-js` is no longer a peer dependency. Now you can use any spec compliant GraphQL engine with `envelop` and get the benefit of building a plugin system. We have introduced a new plugin that can be used to customize the GraphQL Engine.

```diff
- import { envelop } from '@envelop/core'
+ import { envelop, useEngine } from '@envelop/core'
+ import { parse, validate, execute, subscribe } from 'graphql';

- const getEnveloped = envelop([ ... ])
+ const getEnveloped = envelop({ plugins: [useEngine({ parse, validate, execute, subscribe })] })

```

Checkout the [migration guide](https://www.the-guild.dev/graphql/envelop/v3/guides/migrating-from-v2-to-v3) for more details.
5 changes: 5 additions & 0 deletions .changeset/nervous-seas-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@envelop/core': major
---

## Rename `useLazyLoadedSchema` to `useSchemaByContext` since the original name was vert misleading.
27 changes: 27 additions & 0 deletions .changeset/quiet-mice-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
'@envelop/core': major
---

Remove `enableIf` utility in favor of more type safe way to conditionally enable plugins. It wasn't a great experience to have a utility

We can easily replace usage like this:

```diff
- import { envelop, useMaskedErrors, enableIf } from '@envelop/core'
+ import { envelop, useMaskedErrors } from '@envelop/core'
import { parse, validate, execute, subscribe } from 'graphql'

const isProd = process.env.NODE_ENV === 'production'

const getEnveloped = envelop({
parse,
validate,
execute,
subscribe,
plugins: [
// This plugin is enabled only in production
- enableIf(isProd, useMaskedErrors())
+ isProd && useMaskedErrors()
]
})
```
10 changes: 10 additions & 0 deletions .changeset/rude-cats-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@envelop/core': major
---

Remove `handleValidationErrors` and `handleParseErrors` options from `useMaskedErrors`.

> ONLY masking validation errors OR ONLY disabling introspection errors does not make sense, as both can be abused for reverse-engineering the GraphQL schema (see https://github.com/nikitastupin/clairvoyance for reverse-engineering the schema based on validation error suggestions).
> https://github.com/n1ru4l/envelop/issues/1482#issue-1340015060

Rename `formatError` function option to `maskError`
5 changes: 5 additions & 0 deletions .changeset/silent-impalas-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@envelop/core': minor
---

respond to context, parse and validate errors in `useErrorHandler` plugin
7 changes: 7 additions & 0 deletions .changeset/warm-bulldogs-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@envelop/core': major
---

## Removed orchestrator tracing

`GraphQLSchema` was wrapped to provide resolvers/fields tracing from the schema. Issue with this approach was it was very specific to the underlying engine's implementation. With the new version we no longer want to depend to a specific implementation. Now users can wrap their schemas and add tracing themselves.
61 changes: 56 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
{
"parser": "@typescript-eslint/parser",
"extends": ["eslint:recommended", "standard", "prettier", "plugin:@typescript-eslint/recommended"],
"plugins": ["@typescript-eslint", "unicorn"],
"extends": [
"eslint:recommended",
"standard",
"prettier",
"plugin:@typescript-eslint/recommended",
"plugin:package-json/recommended"
],
"plugins": ["@typescript-eslint", "unicorn", "package-json"],
"rules": {
"unicorn/filename-case": "error",
"no-lonely-if": "error",
"unicorn/no-lonely-if": "error",
"no-empty": "off",
"no-console": "error",
"no-prototype-builtins": "off",
"prefer-arrow-callback": ["error", { "allowNamedFunctions": true }],
"prefer-arrow-callback": [
"error",
{
"allowNamedFunctions": true
}
],
"no-useless-constructor": "off",
"@typescript-eslint/no-unused-vars": ["warn", { "args": "none" }],
"no-use-before-define": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"args": "none"
}
],
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-empty-interface": "off",
Expand All @@ -26,7 +43,9 @@
"unicorn/no-useless-fallback-in-spread": "error",
"import/no-extraneous-dependencies": [
"error",
{ "devDependencies": ["**/*.test.ts", "**/*.spec.ts", "**/test/**/*.ts"] }
{
"devDependencies": ["**/*.test.ts", "**/*.spec.ts", "**/test/**/*.ts"]
}
]
},
"env": {
Expand All @@ -43,6 +62,38 @@
"@typescript-eslint/no-unused-vars": "off",
"import/no-extraneous-dependencies": "off"
}
},
// Disallow `graphql-js` specific things to get re-introduced in agnostic packages.
{
"files": [
"packages/core/**",
"packages/types/**",
"packages/plugins/apollo-datasources/**",
"packages/plugins/auth0/**",
"packages/plugins/dataloader/**",
"packages/plugins/preload-assets/**",
"packages/plugins/statsd/**"
],
"env": {
"jest": true
},
"rules": {
"no-restricted-imports": [
"error",
{
"paths": [
{
"name": "graphql",
"message": "You chose violence. Try to make it work without using GraphQL.js"
dotansimha marked this conversation as resolved.
Show resolved Hide resolved
},
{
"name": "@graphql-tools/*",
"message": "You chose violence. Try to make it work without using `graphql-tools`"
}
]
}
]
}
}
],
"ignorePatterns": ["dist", "node_modules", "dev-test", "website"]
Expand Down
35 changes: 30 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,38 @@ jobs:
run: yarn ts:check

unit:
name: unit / ${{matrix.os}} / node v${{matrix.node-version}} / graphql v${{matrix.graphql_version}}
name: Unit Test
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest] # remove windows to speed up the tests
node-version: [12, 17]
graphql_version: [15, 16]
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Setup env
uses: the-guild-org/shared-config/setup@main
with:
nodeVersion: 18
- name: Install Dependencies
run: yarn install --ignore-engines && git checkout yarn.lock
- name: Cache Jest
uses: actions/cache@v2
with:
path: .cache/jest
key: ${{ runner.os }}-${{matrix.node-version}}-${{matrix.graphql_version}}-jest-${{ hashFiles('yarn.lock') }}-${{ hashFiles('patches/*.patch') }}
- name: Test
run: yarn test
env:
CI: true

core:
name: Core Test / ${{matrix.os}} / node v${{matrix.node-version}} / graphql v${{matrix.graphql_version}}
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest] # remove windows to speed up the tests
node-version: [14, 16, 17, 18]
graphql_version: [15, 16, 'npm:@graphql-tools/graphql@0.1.0-alpha-20220815193214-83898018']
steps:
- name: Checkout Master
uses: actions/checkout@v2
Expand All @@ -71,8 +96,8 @@ jobs:
with:
path: .cache/jest
key: ${{ runner.os }}-${{matrix.node-version}}-${{matrix.graphql_version}}-jest-${{ hashFiles('yarn.lock') }}-${{ hashFiles('patches/*.patch') }}
- name: Test
run: yarn test --ci
- name: Test Core
run: yarn test:core --ci
env:
CI: true

Expand Down
9 changes: 7 additions & 2 deletions examples/apollo-server/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable no-console */
import { ApolloServer } from 'apollo-server';
import { envelop, useSchema, useTiming } from '@envelop/core';
import { envelop, useSchema } from '@envelop/core';
import { parse, validate, subscribe, execute } from 'graphql';
import { makeExecutableSchema } from '@graphql-tools/schema';
import { ApolloServerPluginLandingPageGraphQLPlayground } from 'apollo-server-core';

Expand All @@ -18,7 +19,11 @@ const schema = makeExecutableSchema({
});

const getEnveloped = envelop({
plugins: [useSchema(schema), useTiming()],
parse,
validate,
subscribe,
execute,
plugins: [useSchema(schema)],
});

const server = new ApolloServer({
Expand Down
3 changes: 2 additions & 1 deletion examples/apollo-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"@envelop/core": "*",
"apollo-server": "3.5.0",
"apollo-server-core": "3.5.0",
"@graphql-tools/schema": "8.5.0"
"@graphql-tools/schema": "8.5.0",
"graphql": "16.6.0"
},
"devDependencies": {
"@types/node": "15.6.1",
Expand Down
9 changes: 7 additions & 2 deletions examples/azure-functions/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { envelop, useLogger, useSchema, useTiming } from '@envelop/core';
import { envelop, useLogger, useSchema } from '@envelop/core';
import { parse, validate, subscribe, execute } from 'graphql';
import { makeExecutableSchema } from '@graphql-tools/schema';
import { AzureFunction, Context, HttpRequest } from '@azure/functions';
import { getGraphQLParameters, processRequest, Response } from 'graphql-helix';
Expand All @@ -17,7 +18,11 @@ const schema = makeExecutableSchema({
});

const getEnveloped = envelop({
plugins: [useSchema(schema), useLogger(), useTiming()],
parse,
validate,
execute,
subscribe,
plugins: [useSchema(schema), useLogger()],
});

export const index: AzureFunction = async (context: Context, req: HttpRequest): Promise<void> => {
Expand Down
3 changes: 2 additions & 1 deletion examples/azure-functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"dependencies": {
"graphql-helix": "1.8.3",
"@envelop/core": "*",
"@graphql-tools/schema": "8.5.0"
"@graphql-tools/schema": "8.5.0",
"graphql": "16.6.0"
},
"devDependencies": {
"@azure/functions": "1.2.3",
Expand Down
9 changes: 7 additions & 2 deletions examples/cloudflare-workers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { envelop, useLogger, useSchema, useTiming } from '@envelop/core';
import { envelop, useLogger, useSchema } from '@envelop/core';
import { parse, validate, execute, subscribe } from 'graphql';
import { makeExecutableSchema } from '@graphql-tools/schema';
import { getGraphQLParameters, processRequest, Response } from 'graphql-helix';
import { Router } from 'worktop';
Expand All @@ -20,7 +21,11 @@ const schema = makeExecutableSchema({
});

const getEnveloped = envelop({
plugins: [useSchema(schema), useLogger(), useTiming()],
parse,
validate,
execute,
subscribe,
plugins: [useSchema(schema), useLogger()],
});

router.add('POST', '/graphql', async (req, res) => {
Expand Down
Loading