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

introduce simple user provided caches for parse/validate #4285

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/__tests__/starWarsValidation-test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import { parse } from '../language/parser.js';
import { parseSync as parse } from '../language/parser.js';
import { Source } from '../language/source.js';

import { validate } from '../validation/validate.js';
import { validateSync as validate } from '../validation/validate.js';

import { StarWarsSchema } from './starWarsSchema.js';

Expand Down
2 changes: 1 addition & 1 deletion src/error/__tests__/GraphQLError-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { describe, it } from 'mocha';
import { dedent } from '../../__testUtils__/dedent.js';

import { Kind } from '../../language/kinds.js';
import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';
import { Source } from '../../language/source.js';

import { GraphQLError } from '../GraphQLError.js';
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/abort-signal-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expectJSON } from '../../__testUtils__/expectJSON.js';
import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick.js';

import type { DocumentNode } from '../../language/ast.js';
import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import { buildSchema } from '../../utilities/buildASTSchema.js';

Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/abstract-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, it } from 'mocha';

import { expectJSON } from '../../__testUtils__/expectJSON.js';

import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import {
assertInterfaceType,
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/defer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick.js';
import { promiseWithResolvers } from '../../jsutils/promiseWithResolvers.js';

import type { DocumentNode } from '../../language/ast.js';
import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import {
GraphQLList,
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/directives-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import { GraphQLObjectType } from '../../type/definition.js';
import { GraphQLString } from '../../type/scalars.js';
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/executor-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick.js';
import { inspect } from '../../jsutils/inspect.js';

import { Kind } from '../../language/kinds.js';
import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import {
GraphQLInterfaceType,
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/lists-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expectJSON } from '../../__testUtils__/expectJSON.js';

import type { PromiseOrValue } from '../../jsutils/PromiseOrValue.js';

import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import type { GraphQLFieldResolver } from '../../type/definition.js';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/mutations-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { describe, it } from 'mocha';
import { expectJSON } from '../../__testUtils__/expectJSON.js';
import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick.js';

import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import { GraphQLObjectType } from '../../type/definition.js';
import { GraphQLInt } from '../../type/scalars.js';
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/nonnull-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick.js';

import type { PromiseOrValue } from '../../jsutils/PromiseOrValue.js';

import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import { GraphQLNonNull, GraphQLObjectType } from '../../type/definition.js';
import { GraphQLString } from '../../type/scalars.js';
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/oneof-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, it } from 'mocha';

import { expectJSON } from '../../__testUtils__/expectJSON.js';

import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import { buildSchema } from '../../utilities/buildASTSchema.js';

Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/resolve-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import type { GraphQLFieldConfig } from '../../type/definition.js';
import { GraphQLObjectType } from '../../type/definition.js';
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/schema-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import {
GraphQLList,
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/stream-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { PromiseOrValue } from '../../jsutils/PromiseOrValue.js';
import { promiseWithResolvers } from '../../jsutils/promiseWithResolvers.js';

import type { DocumentNode } from '../../language/ast.js';
import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import {
GraphQLList,
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/subscribe-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { isAsyncIterable } from '../../jsutils/isAsyncIterable.js';
import { isPromise } from '../../jsutils/isPromise.js';
import type { PromiseOrValue } from '../../jsutils/PromiseOrValue.js';

import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import { GraphQLList, GraphQLObjectType } from '../../type/definition.js';
import {
Expand Down
4 changes: 2 additions & 2 deletions src/execution/__tests__/sync-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { describe, it } from 'mocha';

import { expectJSON } from '../../__testUtils__/expectJSON.js';

import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import { GraphQLObjectType } from '../../type/definition.js';
import { GraphQLString } from '../../type/scalars.js';
import { GraphQLSchema } from '../../type/schema.js';

import { validate } from '../../validation/validate.js';
import { validateSync as validate } from '../../validation/validate.js';

import { graphqlSync } from '../../graphql.js';

Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/union-interface-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, it } from 'mocha';

import { expectJSON } from '../../__testUtils__/expectJSON.js';

import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import {
GraphQLInterfaceType,
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/variables-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { GraphQLError } from '../../error/GraphQLError.js';

import { DirectiveLocation } from '../../language/directiveLocation.js';
import { Kind } from '../../language/kinds.js';
import { parse } from '../../language/parser.js';
import { parseSync as parse } from '../../language/parser.js';

import type {
GraphQLArgumentConfig,
Expand Down
4 changes: 2 additions & 2 deletions src/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { isPromise } from './jsutils/isPromise.js';
import type { Maybe } from './jsutils/Maybe.js';
import type { PromiseOrValue } from './jsutils/PromiseOrValue.js';

import { parse } from './language/parser.js';
import { parseSync as parse } from './language/parser.js';
import type { Source } from './language/source.js';

import type {
Expand All @@ -12,7 +12,7 @@ import type {
import type { GraphQLSchema } from './type/schema.js';
import { validateSchema } from './type/validate.js';

import { validate } from './validation/validate.js';
import { validateSync as validate } from './validation/validate.js';

import { execute } from './execution/execute.js';
import type { ExecutionResult } from './execution/types.js';
Expand Down
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export {
TokenKind,
// Parse
parse,
parseSync,
parseValue,
parseConstValue,
parseType,
Expand Down Expand Up @@ -247,6 +248,7 @@ export {

export type {
ParseOptions,
ParseCache,
SourceLocation,
// Visitor utilities
ASTVisitor,
Expand Down Expand Up @@ -356,6 +358,7 @@ export type {
// Validate GraphQL documents.
export {
validate,
validateSync,
ValidationContext,
// All validation rules in the GraphQL Specification.
specifiedRules,
Expand Down Expand Up @@ -402,7 +405,11 @@ export {
NoSchemaIntrospectionCustomRule,
} from './validation/index.js';

export type { ValidationRule } from './validation/index.js';
export type {
ValidationRule,
ValidateOptions,
ValidateCache,
} from './validation/index.js';

// Create, format, and print GraphQL errors.
export { GraphQLError, syntaxError, locatedError } from './error/index.js';
Expand Down
Loading
Loading