From eb98ae00277a4e29a95a0bcc2b80e51991d1b8cb Mon Sep 17 00:00:00 2001 From: Yaacov Rydzinski Date: Sun, 29 May 2022 14:17:30 +0300 Subject: [PATCH] Separate interfaces from implementations for exported classes = allows for cross-realm/worker GraphQL = allows for custom implementations of the GraphQL entity implementations, e.g. the `execute` function from GraphQL can be used for any object that implements the `GraphQLSchema` interface, even if does not conform to the default `GraphQLSchemaImpl` class. = currently provides symbols for predicates for the following interfaces: `GraphQLScalarType`, `GraphQLObjectType`, `GraphQLInterfaceType`, `GraphQLUnionType`, `GraphQLEnumType`, `GraphQLInputObjectType`, `GraphQLList`, `GraphQLNonNull`, `GraphQLDirective`, `GraphQLSchema`, and `Source`, i.e. all classes that made internal use of the `instanceOf` method. = the `instanceOf` method now uses symbols instead of `instanceof`. = the exported BREAK object is now passed into the visitor function to allow for cross-compatibility between `graphql` library instances. --- README.md | 4 +- docs-old/APIReference-GraphQL.md | 36 +-- docs-old/APIReference-Language.md | 16 +- docs-old/APIReference-TypeSystem.md | 72 +++--- integrationTests/ts/basic-test.ts | 11 +- integrationTests/ts/extensions-test.ts | 5 +- src/__tests__/starWarsSchema.ts | 48 ++-- src/__tests__/starWarsValidation-test.ts | 4 +- src/error/__tests__/GraphQLError-test.ts | 8 +- src/execution/__tests__/abstract-test.ts | 67 ++--- src/execution/__tests__/directives-test.ts | 8 +- src/execution/__tests__/executor-test.ts | 187 +++++++------- src/execution/__tests__/mutations-test.ts | 12 +- src/execution/__tests__/nonnull-test.ts | 13 +- src/execution/__tests__/resolve-test.ts | 8 +- src/execution/__tests__/schema-test.ts | 25 +- src/execution/__tests__/subscribe-test.ts | 74 +++--- src/execution/__tests__/sync-test.ts | 12 +- .../__tests__/union-interface-test.ts | 50 ++-- src/execution/__tests__/variables-test.ts | 50 ++-- src/index.ts | 45 +++- src/jsutils/__tests__/instanceOf-test.ts | 89 ++----- src/jsutils/instanceOf.ts | 55 ++-- src/language/__tests__/blockString-fuzz.ts | 4 +- src/language/__tests__/lexer-test.ts | 16 +- src/language/__tests__/parser-test.ts | 6 +- src/language/__tests__/printLocation-test.ts | 8 +- src/language/__tests__/source-test.ts | 10 +- src/language/__tests__/visitor-test.ts | 18 +- src/language/index.ts | 5 +- src/language/parser.ts | 5 +- src/language/source.ts | 20 +- src/language/visitor.ts | 5 +- src/type/__tests__/definition-test.ts | 180 ++++++------- src/type/__tests__/directive-test.ts | 26 +- src/type/__tests__/enumType-test.ts | 16 +- src/type/__tests__/extensions-test.ts | 50 ++-- src/type/__tests__/predicate-test.ts | 239 ++++++++++-------- src/type/__tests__/schema-test.ts | 151 +++++------ src/type/__tests__/validation-test.ts | 85 ++++--- src/type/definition.ts | 232 ++++++++++++++--- src/type/directives.ts | 74 ++++-- src/type/index.ts | 39 ++- src/type/introspection.ts | 86 ++++--- src/type/scalars.ts | 14 +- src/type/schema.ts | 63 ++++- src/utilities/__tests__/TypeInfo-test.ts | 4 +- src/utilities/__tests__/astFromValue-test.ts | 36 +-- .../__tests__/buildASTSchema-test.ts | 4 +- .../__tests__/buildClientSchema-test.ts | 12 +- .../__tests__/coerceInputValue-test.ts | 36 +-- src/utilities/__tests__/concatAST-test.ts | 6 +- src/utilities/__tests__/extendSchema-test.ts | 17 +- .../__tests__/findBreakingChanges-test.ts | 6 +- .../__tests__/introspectionFromSchema-test.ts | 8 +- src/utilities/__tests__/printSchema-test.ts | 145 ++++++----- .../__tests__/stripIgnoredCharacters-fuzz.ts | 4 +- .../__tests__/stripIgnoredCharacters-test.ts | 6 +- .../__tests__/typeComparators-test.ts | 58 +++-- src/utilities/__tests__/valueFromAST-test.ts | 32 +-- src/utilities/buildASTSchema.ts | 9 +- src/utilities/buildClientSchema.ts | 52 ++-- src/utilities/entities.ts | 81 ++++++ src/utilities/extendSchema.ts | 67 +++-- src/utilities/index.ts | 20 ++ src/utilities/lexicographicSortSchema.ts | 38 +-- src/utilities/stripIgnoredCharacters.ts | 5 +- src/utilities/typeFromAST.ts | 16 +- .../__tests__/ValidationContext-test.ts | 4 +- .../__tests__/ValuesOfCorrectTypeRule-test.ts | 26 +- 70 files changed, 1712 insertions(+), 1231 deletions(-) create mode 100644 src/utilities/entities.ts diff --git a/README.md b/README.md index d2a91379768..e1e85c6037b 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,8 @@ import { GraphQLString, } from 'graphql'; -var schema = new GraphQLSchema({ - query: new GraphQLObjectType({ +var schema = new GraphQLSchemaImpl({ + query: new GraphQLObjectTypeImpl({ name: 'RootQueryType', fields: { hello: { diff --git a/docs-old/APIReference-GraphQL.md b/docs-old/APIReference-GraphQL.md index 3aea9e87ba9..8781c2e86ee 100644 --- a/docs-old/APIReference-GraphQL.md +++ b/docs-old/APIReference-GraphQL.md @@ -32,8 +32,8 @@ _Schema_