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

Backport 16.x.x into main #4165

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1112b4d
Expose GraphQLErrorOptions type (#3554) (#3565)
IvanGoncharov May 9, 2022
1f8ba95
16.5.0
IvanGoncharov May 9, 2022
59a73d6
createSourceEventStream: introduce named arguments and deprecate posi…
yaacovCR Jun 15, 2022
af8221a
Workaround for codesandbox having bug with TS enums (#3686)
IvanGoncharov Aug 16, 2022
6c6508b
Parser: allow 'options' to explicitly accept undefined (#3701)
IvanGoncharov Aug 16, 2022
f0a0a4d
parser: limit maximum number of tokens (#3702)
IvanGoncharov Aug 16, 2022
3a51eca
16.6.0
IvanGoncharov Aug 16, 2022
4a82557
Fix crash in node when mixing sync/async resolvers (backport of #3706…
chrskrchr Oct 17, 2022
076972e
Fix/invalid error propagation custom scalars (backport for 16.x.x) (#…
stenreijers Feb 15, 2023
84bb146
check "globalThis.process" before accessing it (#3887)
kettanaito May 2, 2023
1519fda
16.7.0
IvanGoncharov Jun 21, 2023
a08aaee
instanceOf: workaround bundler issue with `process.env` (#3923)
IvanGoncharov Jun 22, 2023
bf6a9f0
16.7.1
IvanGoncharov Jun 22, 2023
bec1b49
Support fourfold nested lists (#3950)
gschulze Aug 14, 2023
e4f759d
16.8.0
IvanGoncharov Aug 14, 2023
8f4c64e
OverlappingFieldsCanBeMergedRule: Fix performance degradation (#3967)
AaronMoat Sep 10, 2023
8a95335
16.8.1
IvanGoncharov Sep 19, 2023
0d12b06
fix: remove `globalThis` check and align with what bundlers can accep…
JoviDeCroock May 29, 2024
c82609e
Fix publish scripts (#4104)
benjie Jun 12, 2024
08779a0
16.8.2
benjie Jun 12, 2024
c985c27
backport[v16]: Introduce "recommended" validation rules (#4119)
benjie Jun 21, 2024
29c1bff
feat: allow defining symbol error extensions (#3730)
n1ru4l Jun 21, 2024
c35130e
Revert error extension symbol (#4123)
benjie Jun 21, 2024
29144f7
backport[v16]: Implement OneOf Input Objects via `@oneOf` directive (…
benjie Jun 21, 2024
6a1614c
backport[v16]: Enable passing values configuration to GraphQLEnumType…
benjie Jun 21, 2024
556a01e
16.9.0
benjie Jun 21, 2024
04cba88
Upgrade codecov action and pass token (#4138)
benjie Jul 1, 2024
e1ceb8f
Fix codecov workflow (#4139)
benjie Jul 1, 2024
9a91e33
Add GraphQLConf 2024 banner (#4157)
bignimbus Aug 5, 2024
58aca55
Merge remote-tracking branch 'origin/16.x.x' into backport-16.x.x
JoviDeCroock Aug 15, 2024
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![GraphQLConf 2024 Banner: September 10-12, San Francisco. Hosted by the GraphQL Foundation](https://github.com/user-attachments/assets/2d048502-e5b2-4e9d-a02a-50b841824de6)](https://graphql.org/conf/2024/?utm_source=github&utm_medium=graphql_js&utm_campaign=readme)

# GraphQL.js

The JavaScript reference implementation for GraphQL, a query language for APIs created by Facebook.
Expand Down
7 changes: 7 additions & 0 deletions cspell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ overrides:
words:
- clsx
- infima
- noopener
- Vite
- craco
- esbuild
- swcrc
- noreferrer
- xlink

validateDirectives: true
ignoreRegExpList:
Expand Down
8 changes: 7 additions & 1 deletion src/jsutils/instanceOf.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { inspect } from './inspect.js';

/* c8 ignore next 3 */
const isProduction =
globalThis.process != null &&
// eslint-disable-next-line no-undef
process.env.NODE_ENV === 'production';

/**
* A replacement for instanceof which includes an error warning when multi-realm
* constructors are detected.
Expand All @@ -9,7 +15,7 @@ import { inspect } from './inspect.js';
export const instanceOf: (value: unknown, constructor: Constructor) => boolean =
/* c8 ignore next 6 */
// FIXME: https://github.com/graphql/graphql-js/issues/2317
globalThis.process != null && globalThis.process.env.NODE_ENV === 'production'
isProduction
? function instanceOf(value: unknown, constructor: Constructor): boolean {
return value instanceof constructor;
}
Expand Down
3 changes: 2 additions & 1 deletion src/language/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,12 @@ export interface OperationDefinitionNode {
readonly selectionSet: SelectionSetNode;
}

export enum OperationTypeNode {
enum OperationTypeNode {
QUERY = 'query',
MUTATION = 'mutation',
SUBSCRIPTION = 'subscription',
}
export { OperationTypeNode };

export interface VariableDefinitionNode {
readonly kind: Kind.VARIABLE_DEFINITION;
Expand Down
4 changes: 3 additions & 1 deletion src/language/directiveLocation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* The set of allowed directive location values.
*/
export enum DirectiveLocation {
enum DirectiveLocation {
/** Request Definitions */
QUERY = 'QUERY',
MUTATION = 'MUTATION',
Expand All @@ -24,3 +24,5 @@ export enum DirectiveLocation {
INPUT_OBJECT = 'INPUT_OBJECT',
INPUT_FIELD_DEFINITION = 'INPUT_FIELD_DEFINITION',
}

export { DirectiveLocation };
4 changes: 3 additions & 1 deletion src/language/kinds.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* The set of allowed kind values for AST nodes.
*/
export enum Kind {
enum Kind {
/** Name */
NAME = 'Name',

Expand Down Expand Up @@ -72,3 +72,5 @@ export enum Kind {
ENUM_TYPE_EXTENSION = 'EnumTypeExtension',
INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension',
}

export { Kind };
4 changes: 3 additions & 1 deletion src/language/tokenKind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* An exported enum describing the different kinds of tokens that the
* lexer emits.
*/
export enum TokenKind {
enum TokenKind {
SOF = '<SOF>',
EOF = '<EOF>',
BANG = '!',
Expand All @@ -27,3 +27,5 @@ export enum TokenKind {
BLOCK_STRING = 'BlockString',
COMMENT = 'Comment',
}

export { TokenKind };
3 changes: 2 additions & 1 deletion src/type/introspection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ export const __EnumValue: GraphQLObjectType = new GraphQLObjectType({
} as GraphQLFieldConfigMap<GraphQLEnumValue, unknown>),
});

export enum TypeKind {
enum TypeKind {
SCALAR = 'SCALAR',
OBJECT = 'OBJECT',
INTERFACE = 'INTERFACE',
Expand All @@ -453,6 +453,7 @@ export enum TypeKind {
LIST = 'LIST',
NON_NULL = 'NON_NULL',
}
export { TypeKind };

export const __TypeKind: GraphQLEnumType = new GraphQLEnumType({
name: '__TypeKind',
Expand Down
6 changes: 4 additions & 2 deletions src/utilities/findBreakingChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import type { GraphQLSchema } from '../type/schema.js';
import { astFromValue } from './astFromValue.js';
import { sortValueNode } from './sortValueNode.js';

export enum BreakingChangeType {
enum BreakingChangeType {
TYPE_REMOVED = 'TYPE_REMOVED',
TYPE_CHANGED_KIND = 'TYPE_CHANGED_KIND',
TYPE_REMOVED_FROM_UNION = 'TYPE_REMOVED_FROM_UNION',
Expand All @@ -52,15 +52,17 @@ export enum BreakingChangeType {
DIRECTIVE_REPEATABLE_REMOVED = 'DIRECTIVE_REPEATABLE_REMOVED',
DIRECTIVE_LOCATION_REMOVED = 'DIRECTIVE_LOCATION_REMOVED',
}
export { BreakingChangeType };

export enum DangerousChangeType {
enum DangerousChangeType {
VALUE_ADDED_TO_ENUM = 'VALUE_ADDED_TO_ENUM',
TYPE_ADDED_TO_UNION = 'TYPE_ADDED_TO_UNION',
OPTIONAL_INPUT_FIELD_ADDED = 'OPTIONAL_INPUT_FIELD_ADDED',
OPTIONAL_ARG_ADDED = 'OPTIONAL_ARG_ADDED',
IMPLEMENTED_INTERFACE_ADDED = 'IMPLEMENTED_INTERFACE_ADDED',
ARG_DEFAULT_VALUE_CHANGE = 'ARG_DEFAULT_VALUE_CHANGE',
}
export { DangerousChangeType };

export interface BreakingChange {
type: BreakingChangeType;
Expand Down
127 changes: 127 additions & 0 deletions website/docs/tutorials/going-to-production.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
title: Going to production
category: FAQ
---

GraphQL.JS contains a few development checks which in production will cause slower performance and
an increase in bundle-size. Every bundler goes about these changes different, in here we'll list
out the most popular ones.

## Bundler-specific configuration

Here are some bundler-specific suggestions for configuring your bundler to remove `globalThis.process` and `process.env.NODE_ENV` on build time.

### Vite

```js
export default defineConfig({
// ...
define: {
'globalThis.process': JSON.stringify(true),
'process.env.NODE_ENV': JSON.stringify('production'),
},
});
```

### Next.js

```js
// ...
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack(config, { webpack }) {
config.plugins.push(
new webpack.DefinePlugin({
'globalThis.process': JSON.stringify(true),
'process.env.NODE_ENV': JSON.stringify('production'),
}),
);
return config;
},
};

module.exports = nextConfig;
```

### create-react-app

With `create-react-app`, you need to use a third-party package like [`craco`](https://craco.js.org/) to modify the bundler configuration.

```js
const webpack = require('webpack');
module.exports = {
webpack: {
plugins: [
new webpack.DefinePlugin({
'globalThis.process': JSON.stringify(true),
'process.env.NODE_ENV': JSON.stringify('production'),
}),
],
},
};
```

### esbuild

```json
{
"define": {
"globalThis.process": true,
"process.env.NODE_ENV": "production"
}
}
```

### Webpack

```js
config.plugins.push(
new webpack.DefinePlugin({
'globalThis.process': JSON.stringify(true),
'process.env.NODE_ENV': JSON.stringify('production'),
}),
);
```

### Rollup

```js
export default [
{
// ... input, output, etc.
plugins: [
minify({
mangle: {
toplevel: true,
},
compress: {
toplevel: true,
global_defs: {
'@globalThis.process': JSON.stringify(true),
'@process.env.NODE_ENV': JSON.stringify('production'),
},
},
}),
],
},
];
```

### SWC

```json title=".swcrc"
{
"jsc": {
"transform": {
"optimizer": {
"globals": {
"vars": {
"globalThis.process": true,
"process.env.NODE_ENV": "production"
}
}
}
}
}
}
```
5 changes: 5 additions & 0 deletions website/sidebars.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ module.exports = {
label: 'Advanced',
items: ['tutorials/constructing-types'],
},
{
type: 'category',
label: 'FAQ',
items: ['tutorials/going-to-production'],
},
'tutorials/express-graphql',
'tutorials/defer-stream',
],
Expand Down
Loading