Skip to content

Commit b95bc51

Browse files
committed
Merge remote-tracking branch 'origin/16.x.x' into backport-16.x.x
2 parents 5c7d4d1 + 9a91e33 commit b95bc51

File tree

16 files changed

+198
-9
lines changed

16 files changed

+198
-9
lines changed

.github/workflows/pull_request.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ jobs:
77
contents: read # for actions/checkout
88
security-events: write # for codeql-action
99
uses: ./.github/workflows/ci.yml
10+
secrets:
11+
codecov_token: ${{ secrets.CODECOV_TOKEN }}
1012

1113
dependency-review:
1214
name: Security check of added dependencies

.github/workflows/push.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ jobs:
77
contents: read # for actions/checkout
88
security-events: write
99
uses: ./.github/workflows/ci.yml
10+
secrets:
11+
codecov_token: ${{ secrets.CODECOV_TOKEN }}
1012
deploy-to-npm-branch:
1113
name: Deploy to `npm` branch
1214
needs: ci

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![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)
2+
13
# GraphQL.js
24

35
The JavaScript reference implementation for GraphQL, a query language for APIs created by Facebook.

cspell.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ overrides:
2020
words:
2121
- clsx
2222
- infima
23+
- noopener
24+
- Vite
25+
- craco
26+
- esbuild
27+
- swcrc
28+
- noreferrer
29+
- xlink
2330

2431
validateDirectives: true
2532
ignoreRegExpList:

src/execution/__tests__/variables-test.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const TestFaultyScalarGraphQLError = new GraphQLError(
3232
'FaultyScalarErrorMessage',
3333
{
3434
extensions: {
35-
code: 'FaultyScalarErrorExtensionCode',
35+
code: 'FaultyScalarErrorMessageExtensionCode',
3636
},
3737
},
3838
);
@@ -271,6 +271,27 @@ describe('Execute: Handles inputs', () => {
271271
});
272272
});
273273

274+
it('errors on faulty scalar type input', () => {
275+
const result = executeQuery(`
276+
{
277+
fieldWithObjectInput(input: {c: "foo", e: "bar"})
278+
}
279+
`);
280+
281+
expectJSON(result).toDeepEqual({
282+
data: {
283+
fieldWithObjectInput: null,
284+
},
285+
errors: [
286+
{
287+
message: 'Argument "input" has invalid value {c: "foo", e: "bar"}.',
288+
path: ['fieldWithObjectInput'],
289+
locations: [{ line: 3, column: 39 }],
290+
},
291+
],
292+
});
293+
});
294+
274295
describe('using variables', () => {
275296
const doc = `
276297
query ($input: TestInputObject) {

src/jsutils/instanceOf.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { inspect } from './inspect.js';
22

3+
/* c8 ignore next 3 */
4+
const isProduction =
5+
globalThis.process &&
6+
// eslint-disable-next-line no-undef
7+
process.env.NODE_ENV === 'production';
8+
39
/**
410
* A replacement for instanceof which includes an error warning when multi-realm
511
* constructors are detected.
@@ -9,7 +15,7 @@ import { inspect } from './inspect.js';
915
export const instanceOf: (value: unknown, constructor: Constructor) => boolean =
1016
/* c8 ignore next 6 */
1117
// FIXME: https://github.com/graphql/graphql-js/issues/2317
12-
globalThis.process != null && globalThis.process.env.NODE_ENV === 'production'
18+
isProduction
1319
? function instanceOf(value: unknown, constructor: Constructor): boolean {
1420
return value instanceof constructor;
1521
}

src/language/ast.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,12 @@ export interface OperationDefinitionNode {
343343
readonly selectionSet: SelectionSetNode;
344344
}
345345

346-
export enum OperationTypeNode {
346+
enum OperationTypeNode {
347347
QUERY = 'query',
348348
MUTATION = 'mutation',
349349
SUBSCRIPTION = 'subscription',
350350
}
351+
export { OperationTypeNode };
351352

352353
export interface VariableDefinitionNode {
353354
readonly kind: Kind.VARIABLE_DEFINITION;

src/language/directiveLocation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* The set of allowed directive location values.
33
*/
4-
export enum DirectiveLocation {
4+
enum DirectiveLocation {
55
/** Request Definitions */
66
QUERY = 'QUERY',
77
MUTATION = 'MUTATION',

src/language/kinds.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* The set of allowed kind values for AST nodes.
33
*/
4-
export enum Kind {
4+
enum Kind {
55
/** Name */
66
NAME = 'Name',
77

@@ -72,3 +72,5 @@ export enum Kind {
7272
ENUM_TYPE_EXTENSION = 'EnumTypeExtension',
7373
INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension',
7474
}
75+
76+
export { Kind };

src/language/parser.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ export interface ParseOptions {
9191
*/
9292
maxTokens?: number | undefined;
9393

94+
/**
95+
* Parser CPU and memory usage is linear to the number of tokens in a document
96+
* however in extreme cases it becomes quadratic due to memory exhaustion.
97+
* Parsing happens before validation so even invalid queries can burn lots of
98+
* CPU time and memory.
99+
* To prevent this you can set a maximum number of tokens allowed within a document.
100+
*/
101+
maxTokens?: number | undefined;
102+
94103
/**
95104
* @deprecated will be removed in the v17.0.0
96105
*

0 commit comments

Comments
 (0)