From 6258cd7cb706613c39f0c4b4a9df3ada89efe973 Mon Sep 17 00:00:00 2001 From: Kei Kamikawa Date: Sun, 11 Apr 2021 00:15:01 +0900 Subject: [PATCH 1/4] fixed API Reference for specifiedBy --- docs/APIReference-TypeSystem.md | 2 +- src/type/definition.d.ts | 6 +++--- src/type/definition.js | 15 +++++++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/docs/APIReference-TypeSystem.md b/docs/APIReference-TypeSystem.md index 8efd840eb6..7f640dc167 100644 --- a/docs/APIReference-TypeSystem.md +++ b/docs/APIReference-TypeSystem.md @@ -206,7 +206,7 @@ class GraphQLScalarType { type GraphQLScalarTypeConfig = { name: string; description?: ?string; - specifiedByUrl?: string; + specifiedBy?: string; serialize: (value: mixed) => ?InternalType; parseValue?: (value: mixed) => ?InternalType; parseLiteral?: (valueAST: Value) => ?InternalType; diff --git a/src/type/definition.d.ts b/src/type/definition.d.ts index 50ee968b03..605fd97fef 100644 --- a/src/type/definition.d.ts +++ b/src/type/definition.d.ts @@ -304,7 +304,7 @@ export interface GraphQLScalarTypeExtensions { export class GraphQLScalarType { name: string; description: Maybe; - specifiedByUrl: Maybe; + specifiedBy: Maybe; serialize: GraphQLScalarSerializer; parseValue: GraphQLScalarValueParser; parseLiteral: GraphQLScalarLiteralParser; @@ -315,7 +315,7 @@ export class GraphQLScalarType { constructor(config: Readonly>); toConfig(): GraphQLScalarTypeConfig & { - specifiedByUrl: Maybe; + specifiedBy: Maybe; serialize: GraphQLScalarSerializer; parseValue: GraphQLScalarValueParser; parseLiteral: GraphQLScalarLiteralParser; @@ -342,7 +342,7 @@ export type GraphQLScalarLiteralParser = ( export interface GraphQLScalarTypeConfig { name: string; description?: Maybe; - specifiedByUrl?: Maybe; + specifiedBy?: Maybe; // Serializes an internal value to include in a response. serialize?: GraphQLScalarSerializer; // Parses an externally provided value to use as an input. diff --git a/src/type/definition.js b/src/type/definition.js index 04c5f05ef3..68dd9bdaba 100644 --- a/src/type/definition.js +++ b/src/type/definition.js @@ -549,7 +549,7 @@ function resolveObjMapThunk(thunk: ThunkObjMap): ObjMap { export class GraphQLScalarType { name: string; description: ?string; - specifiedByUrl: ?string; + specifiedBy: ?string; serialize: GraphQLScalarSerializer; parseValue: GraphQLScalarValueParser; parseLiteral: GraphQLScalarLiteralParser; @@ -561,7 +561,7 @@ export class GraphQLScalarType { const parseValue = config.parseValue ?? identityFunc; this.name = config.name; this.description = config.description; - this.specifiedByUrl = config.specifiedByUrl; + this.specifiedBy = config.specifiedBy; this.serialize = config.serialize ?? identityFunc; this.parseValue = parseValue; this.parseLiteral = @@ -574,10 +574,9 @@ export class GraphQLScalarType { devAssert(typeof config.name === 'string', 'Must provide name.'); devAssert( - config.specifiedByUrl == null || - typeof config.specifiedByUrl === 'string', - `${this.name} must provide "specifiedByUrl" as a string, ` + - `but got: ${inspect(config.specifiedByUrl)}.`, + config.specifiedBy == null || typeof config.specifiedBy === 'string', + `${this.name} must provide "specifiedBy" as a string, ` + + `but got: ${inspect(config.specifiedBy)}.`, ); devAssert( @@ -598,7 +597,7 @@ export class GraphQLScalarType { return { name: this.name, description: this.description, - specifiedByUrl: this.specifiedByUrl, + specifiedBy: this.specifiedBy, serialize: this.serialize, parseValue: this.parseValue, parseLiteral: this.parseLiteral, @@ -638,7 +637,7 @@ export type GraphQLScalarLiteralParser = ( export type GraphQLScalarTypeConfig = {| name: string, description?: ?string, - specifiedByUrl?: ?string, + specifiedBy?: ?string, // Serializes an internal value to include in a response. serialize?: GraphQLScalarSerializer, // Parses an externally provided value to use as an input. From eb9d2d6a9eaf271e84c324915c4d65064bd31f4d Mon Sep 17 00:00:00 2001 From: Kei Kamikawa Date: Sun, 11 Apr 2021 00:16:35 +0900 Subject: [PATCH 2/4] use "specifiedBy" instead of "specifiedByUrl" --- src/type/__tests__/definition-test.js | 10 +++---- src/type/__tests__/introspection-test.js | 26 +++++++++---------- src/type/introspection.js | 6 ++--- .../__tests__/buildASTSchema-test.js | 2 +- src/utilities/__tests__/extendSchema-test.js | 2 +- .../__tests__/getIntrospectionQuery-test.js | 10 +++---- src/utilities/__tests__/printSchema-test.js | 8 +++--- src/utilities/buildClientSchema.js | 2 +- src/utilities/extendSchema.js | 12 ++++----- src/utilities/getIntrospectionQuery.d.ts | 4 +-- src/utilities/getIntrospectionQuery.js | 6 ++--- src/utilities/printSchema.js | 8 +++--- 12 files changed, 46 insertions(+), 50 deletions(-) diff --git a/src/type/__tests__/definition-test.js b/src/type/__tests__/definition-test.js index faefd625d6..99ff229e98 100644 --- a/src/type/__tests__/definition-test.js +++ b/src/type/__tests__/definition-test.js @@ -46,12 +46,12 @@ describe('Type System: Scalars', () => { expect(() => new GraphQLScalarType({ name: 'SomeScalar' })).to.not.throw(); }); - it('accepts a Scalar type defining specifiedByUrl', () => { + it('accepts a Scalar type defining specifiedBy', () => { expect( () => new GraphQLScalarType({ name: 'SomeScalar', - specifiedByUrl: 'https://example.com/foo_spec', + specifiedBy: 'https://example.com/foo_spec', }), ).not.to.throw(); }); @@ -139,16 +139,16 @@ describe('Type System: Scalars', () => { ); }); - it('rejects a Scalar type defining specifiedByUrl with an incorrect type', () => { + it('rejects a Scalar type defining specifiedBy with an incorrect type', () => { expect( () => new GraphQLScalarType({ name: 'SomeScalar', // $FlowExpectedError[incompatible-call] - specifiedByUrl: {}, + specifiedBy: {}, }), ).to.throw( - 'SomeScalar must provide "specifiedByUrl" as a string, but got: {}.', + 'SomeScalar must provide "specifiedBy" as a string, but got: {}.', ); }); }); diff --git a/src/type/__tests__/introspection-test.js b/src/type/__tests__/introspection-test.js index 2e5f261e94..d4f8b1446f 100644 --- a/src/type/__tests__/introspection-test.js +++ b/src/type/__tests__/introspection-test.js @@ -35,7 +35,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: 'SomeObject', - specifiedByUrl: null, + specifiedBy: null, fields: [ { name: 'someField', @@ -57,7 +57,7 @@ describe('Introspection', () => { { kind: 'SCALAR', name: 'String', - specifiedByUrl: null, + specifiedBy: null, fields: null, inputFields: null, interfaces: null, @@ -67,7 +67,7 @@ describe('Introspection', () => { { kind: 'SCALAR', name: 'Boolean', - specifiedByUrl: null, + specifiedBy: null, fields: null, inputFields: null, interfaces: null, @@ -77,7 +77,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__Schema', - specifiedByUrl: null, + specifiedBy: null, fields: [ { name: 'description', @@ -182,7 +182,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__Type', - specifiedByUrl: null, + specifiedBy: null, fields: [ { name: 'kind', @@ -222,7 +222,7 @@ describe('Introspection', () => { deprecationReason: null, }, { - name: 'specifiedByUrl', + name: 'specifiedBy', args: [], type: { kind: 'SCALAR', @@ -377,7 +377,7 @@ describe('Introspection', () => { { kind: 'ENUM', name: '__TypeKind', - specifiedByUrl: null, + specifiedBy: null, fields: null, inputFields: null, interfaces: null, @@ -428,7 +428,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__Field', - specifiedByUrl: null, + specifiedBy: null, fields: [ { name: 'name', @@ -539,7 +539,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__InputValue', - specifiedByUrl: null, + specifiedBy: null, fields: [ { name: 'name', @@ -628,7 +628,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__EnumValue', - specifiedByUrl: null, + specifiedBy: null, fields: [ { name: 'name', @@ -691,7 +691,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__Directive', - specifiedByUrl: null, + specifiedBy: null, fields: [ { name: 'name', @@ -789,7 +789,7 @@ describe('Introspection', () => { { kind: 'ENUM', name: '__DirectiveLocation', - specifiedByUrl: null, + specifiedBy: null, fields: null, inputFields: null, interfaces: null, @@ -1560,7 +1560,7 @@ describe('Introspection', () => { `); const source = getIntrospectionQuery({ - specifiedByUrl: true, + specifiedBy: true, directiveIsRepeatable: true, schemaDescription: true, }); diff --git a/src/type/introspection.js b/src/type/introspection.js index 826fb58aa8..fd46ad4e10 100644 --- a/src/type/introspection.js +++ b/src/type/introspection.js @@ -196,7 +196,7 @@ export const __DirectiveLocation: GraphQLEnumType = new GraphQLEnumType({ export const __Type: GraphQLObjectType = new GraphQLObjectType({ name: '__Type', description: - 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByUrl`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.', + 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedBy`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.', fields: () => ({ kind: { @@ -241,10 +241,10 @@ export const __Type: GraphQLObjectType = new GraphQLObjectType({ resolve: (type) => type.description !== undefined ? type.description : undefined, }, - specifiedByUrl: { + specifiedBy: { type: GraphQLString, resolve: (obj) => - obj.specifiedByUrl !== undefined ? obj.specifiedByUrl : undefined, + obj.specifiedBy !== undefined ? obj.specifiedBy : undefined, }, fields: { type: new GraphQLList(new GraphQLNonNull(__Field)), diff --git a/src/utilities/__tests__/buildASTSchema-test.js b/src/utilities/__tests__/buildASTSchema-test.js index a315a08422..5f45261c70 100644 --- a/src/utilities/__tests__/buildASTSchema-test.js +++ b/src/utilities/__tests__/buildASTSchema-test.js @@ -707,7 +707,7 @@ describe('Schema Builder', () => { const schema = buildSchema(sdl); expect(schema.getType('Foo')).to.include({ - specifiedByUrl: 'https://example.com/foo_spec', + specifiedBy: 'https://example.com/foo_spec', }); }); diff --git a/src/utilities/__tests__/extendSchema-test.js b/src/utilities/__tests__/extendSchema-test.js index 7f358ade6e..8c0b5b3322 100644 --- a/src/utilities/__tests__/extendSchema-test.js +++ b/src/utilities/__tests__/extendSchema-test.js @@ -315,7 +315,7 @@ describe('extendSchema', () => { const extendedSchema = extendSchema(schema, parse(extensionSDL)); const foo = assertScalarType(extendedSchema.getType('Foo')); - expect(foo.specifiedByUrl).to.equal('https://example.com/foo_spec'); + expect(foo.specifiedBy).to.equal('https://example.com/foo_spec'); expect(validateSchema(extendedSchema)).to.deep.equal([]); expectExtensionASTNodes(foo).to.equal(extensionSDL); diff --git a/src/utilities/__tests__/getIntrospectionQuery-test.js b/src/utilities/__tests__/getIntrospectionQuery-test.js index 3f0c36298f..2ded7c37c0 100644 --- a/src/utilities/__tests__/getIntrospectionQuery-test.js +++ b/src/utilities/__tests__/getIntrospectionQuery-test.js @@ -63,15 +63,13 @@ describe('getIntrospectionQuery', () => { }).toNotMatch('description'); }); - it('include "specifiedByUrl" field', () => { - expectIntrospectionQuery().toNotMatch('specifiedByUrl'); + it('include "specifiedBy" field', () => { + expectIntrospectionQuery().toNotMatch('specifiedBy'); - expectIntrospectionQuery({ specifiedByUrl: true }).toMatch( - 'specifiedByUrl', - ); + expectIntrospectionQuery({ specifiedByUrl: true }).toMatch('specifiedBy'); expectIntrospectionQuery({ specifiedByUrl: false }).toNotMatch( - 'specifiedByUrl', + 'specifiedBy', ); }); diff --git a/src/utilities/__tests__/printSchema-test.js b/src/utilities/__tests__/printSchema-test.js index cdd4ca574c..ebcb8898c7 100644 --- a/src/utilities/__tests__/printSchema-test.js +++ b/src/utilities/__tests__/printSchema-test.js @@ -495,10 +495,10 @@ describe('Type System Printer', () => { `); }); - it('Custom Scalar with specifiedByUrl', () => { + it('Custom Scalar with specifiedBy', () => { const FooType = new GraphQLScalarType({ name: 'Foo', - specifiedByUrl: 'https://example.com/foo_spec', + specifiedBy: 'https://example.com/foo_spec', }); const schema = new GraphQLSchema({ types: [FooType] }); @@ -670,13 +670,13 @@ describe('Type System Printer', () => { """ The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the \`__TypeKind\` enum. - Depending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional \`specifiedByUrl\`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types. + Depending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional \`specifiedBy\`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types. """ type __Type { kind: __TypeKind! name: String description: String - specifiedByUrl: String + specifiedBy: String fields(includeDeprecated: Boolean = false): [__Field!] interfaces: [__Type!] possibleTypes: [__Type!] diff --git a/src/utilities/buildClientSchema.js b/src/utilities/buildClientSchema.js index dd03316a45..abfcb8a019 100644 --- a/src/utilities/buildClientSchema.js +++ b/src/utilities/buildClientSchema.js @@ -201,7 +201,7 @@ export function buildClientSchema( return new GraphQLScalarType({ name: scalarIntrospection.name, description: scalarIntrospection.description, - specifiedByUrl: scalarIntrospection.specifiedByUrl, + specifiedBy: scalarIntrospection.specifiedBy, }); } diff --git a/src/utilities/extendSchema.js b/src/utilities/extendSchema.js index ba79e9645f..3e2e6bf26f 100644 --- a/src/utilities/extendSchema.js +++ b/src/utilities/extendSchema.js @@ -310,14 +310,14 @@ export function extendSchemaImpl( const config = type.toConfig(); const extensions = typeExtensionsMap[config.name] ?? []; - let specifiedByUrl = config.specifiedByUrl; + let specifiedBy = config.specifiedBy; for (const extensionNode of extensions) { - specifiedByUrl = getSpecifiedByUrl(extensionNode) ?? specifiedByUrl; + specifiedBy = getSpecifiedBy(extensionNode) ?? specifiedBy; } return new GraphQLScalarType({ ...config, - specifiedByUrl, + specifiedBy, extensionASTNodes: config.extensionASTNodes.concat(extensions), }); } @@ -655,7 +655,7 @@ export function extendSchemaImpl( return new GraphQLScalarType({ name, description: astNode.description?.value, - specifiedByUrl: getSpecifiedByUrl(astNode), + specifiedBy: getSpecifiedBy(astNode), astNode, extensionASTNodes, }); @@ -702,9 +702,9 @@ function getDeprecationReason( } /** - * Given a scalar node, returns the string value for the specifiedByUrl. + * Given a scalar node, returns the string value for the specifiedBy. */ -function getSpecifiedByUrl( +function getSpecifiedBy( node: ScalarTypeDefinitionNode | ScalarTypeExtensionNode, ): ?string { const specifiedBy = getDirectiveValues(GraphQLSpecifiedByDirective, node); diff --git a/src/utilities/getIntrospectionQuery.d.ts b/src/utilities/getIntrospectionQuery.d.ts index fd550ad36c..49745cb0aa 100644 --- a/src/utilities/getIntrospectionQuery.d.ts +++ b/src/utilities/getIntrospectionQuery.d.ts @@ -7,7 +7,7 @@ export interface IntrospectionOptions { // Default: true descriptions?: boolean; - // Whether to include `specifiedByUrl` in the introspection result. + // Whether to include `specifiedBy` in the introspection result. // Default: false specifiedByUrl?: boolean; @@ -67,7 +67,7 @@ export interface IntrospectionScalarType { readonly kind: 'SCALAR'; readonly name: string; readonly description?: Maybe; - readonly specifiedByUrl?: Maybe; + readonly specifiedBy?: Maybe; } export interface IntrospectionObjectType { diff --git a/src/utilities/getIntrospectionQuery.js b/src/utilities/getIntrospectionQuery.js index 1c9abb4204..d08285ebec 100644 --- a/src/utilities/getIntrospectionQuery.js +++ b/src/utilities/getIntrospectionQuery.js @@ -33,9 +33,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string { }; const descriptions = optionsWithDefault.descriptions ? 'description' : ''; - const specifiedByUrl = optionsWithDefault.specifiedByUrl - ? 'specifiedByUrl' - : ''; + const specifiedByUrl = optionsWithDefault.specifiedByUrl ? 'specifiedBy' : ''; const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable ? 'isRepeatable' : ''; @@ -184,7 +182,7 @@ export type IntrospectionScalarType = {| +kind: 'SCALAR', +name: string, +description?: ?string, - +specifiedByUrl?: ?string, + +specifiedBy?: ?string, |}; export type IntrospectionObjectType = {| diff --git a/src/utilities/printSchema.js b/src/utilities/printSchema.js index f2a4d15226..36431d2bd7 100644 --- a/src/utilities/printSchema.js +++ b/src/utilities/printSchema.js @@ -150,7 +150,7 @@ export function printType(type: GraphQLNamedType): string { function printScalar(type: GraphQLScalarType): string { return ( - printDescription(type) + `scalar ${type.name}` + printSpecifiedByUrl(type) + printDescription(type) + `scalar ${type.name}` + printSpecifiedBy(type) ); } @@ -288,11 +288,11 @@ function printDeprecated(reason: ?string): string { return ' @deprecated'; } -function printSpecifiedByUrl(scalar: GraphQLScalarType): string { - if (scalar.specifiedByUrl == null) { +function printSpecifiedBy(scalar: GraphQLScalarType): string { + if (scalar.specifiedBy == null) { return ''; } - const url = scalar.specifiedByUrl; + const url = scalar.specifiedBy; const urlAST = astFromValue(url, GraphQLString); invariant( urlAST, From 83c243199cfabe53130a0309a1e92b48c1959a5a Mon Sep 17 00:00:00 2001 From: Kei Kamikawa Date: Sun, 11 Apr 2021 00:24:37 +0900 Subject: [PATCH 3/4] fixed getIntrospectionQuery in test --- src/type/__tests__/introspection-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/type/__tests__/introspection-test.js b/src/type/__tests__/introspection-test.js index d4f8b1446f..818eae2c52 100644 --- a/src/type/__tests__/introspection-test.js +++ b/src/type/__tests__/introspection-test.js @@ -1560,7 +1560,7 @@ describe('Introspection', () => { `); const source = getIntrospectionQuery({ - specifiedBy: true, + specifiedByUrl: true, directiveIsRepeatable: true, schemaDescription: true, }); From 04fa14fc70ca4646bc0db6d656201d135052df3a Mon Sep 17 00:00:00 2001 From: Kei Kamikawa Date: Wed, 14 Apr 2021 11:29:35 +0900 Subject: [PATCH 4/4] use "specifiedByURL" instead of "specifiedBy" See: https://github.com/graphql/graphql-spec/pull/848 --- docs/APIReference-TypeSystem.md | 2 +- src/type/__tests__/definition-test.js | 10 ++++---- src/type/__tests__/introspection-test.js | 24 +++++++++---------- src/type/definition.d.ts | 4 ++-- src/type/definition.js | 15 ++++++------ src/type/introspection.js | 6 ++--- .../__tests__/buildASTSchema-test.js | 2 +- src/utilities/__tests__/extendSchema-test.js | 2 +- .../__tests__/getIntrospectionQuery-test.js | 8 ++++--- src/utilities/__tests__/printSchema-test.js | 8 +++---- src/utilities/buildClientSchema.js | 2 +- src/utilities/extendSchema.js | 12 +++++----- src/utilities/getIntrospectionQuery.d.ts | 4 ++-- src/utilities/getIntrospectionQuery.js | 6 +++-- src/utilities/printSchema.js | 10 ++++---- 15 files changed, 60 insertions(+), 55 deletions(-) diff --git a/docs/APIReference-TypeSystem.md b/docs/APIReference-TypeSystem.md index 7f640dc167..5b5047c349 100644 --- a/docs/APIReference-TypeSystem.md +++ b/docs/APIReference-TypeSystem.md @@ -206,7 +206,7 @@ class GraphQLScalarType { type GraphQLScalarTypeConfig = { name: string; description?: ?string; - specifiedBy?: string; + specifiedByURL?: string; serialize: (value: mixed) => ?InternalType; parseValue?: (value: mixed) => ?InternalType; parseLiteral?: (valueAST: Value) => ?InternalType; diff --git a/src/type/__tests__/definition-test.js b/src/type/__tests__/definition-test.js index 99ff229e98..809e7007d3 100644 --- a/src/type/__tests__/definition-test.js +++ b/src/type/__tests__/definition-test.js @@ -46,12 +46,12 @@ describe('Type System: Scalars', () => { expect(() => new GraphQLScalarType({ name: 'SomeScalar' })).to.not.throw(); }); - it('accepts a Scalar type defining specifiedBy', () => { + it('accepts a Scalar type defining specifiedByURL', () => { expect( () => new GraphQLScalarType({ name: 'SomeScalar', - specifiedBy: 'https://example.com/foo_spec', + specifiedByURL: 'https://example.com/foo_spec', }), ).not.to.throw(); }); @@ -139,16 +139,16 @@ describe('Type System: Scalars', () => { ); }); - it('rejects a Scalar type defining specifiedBy with an incorrect type', () => { + it('rejects a Scalar type defining specifiedByURL with an incorrect type', () => { expect( () => new GraphQLScalarType({ name: 'SomeScalar', // $FlowExpectedError[incompatible-call] - specifiedBy: {}, + specifiedByURL: {}, }), ).to.throw( - 'SomeScalar must provide "specifiedBy" as a string, but got: {}.', + 'SomeScalar must provide "specifiedByURL" as a string, but got: {}.', ); }); }); diff --git a/src/type/__tests__/introspection-test.js b/src/type/__tests__/introspection-test.js index 818eae2c52..9db9470e97 100644 --- a/src/type/__tests__/introspection-test.js +++ b/src/type/__tests__/introspection-test.js @@ -35,7 +35,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: 'SomeObject', - specifiedBy: null, + specifiedByURL: null, fields: [ { name: 'someField', @@ -57,7 +57,7 @@ describe('Introspection', () => { { kind: 'SCALAR', name: 'String', - specifiedBy: null, + specifiedByURL: null, fields: null, inputFields: null, interfaces: null, @@ -67,7 +67,7 @@ describe('Introspection', () => { { kind: 'SCALAR', name: 'Boolean', - specifiedBy: null, + specifiedByURL: null, fields: null, inputFields: null, interfaces: null, @@ -77,7 +77,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__Schema', - specifiedBy: null, + specifiedByURL: null, fields: [ { name: 'description', @@ -182,7 +182,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__Type', - specifiedBy: null, + specifiedByURL: null, fields: [ { name: 'kind', @@ -222,7 +222,7 @@ describe('Introspection', () => { deprecationReason: null, }, { - name: 'specifiedBy', + name: 'specifiedByURL', args: [], type: { kind: 'SCALAR', @@ -377,7 +377,7 @@ describe('Introspection', () => { { kind: 'ENUM', name: '__TypeKind', - specifiedBy: null, + specifiedByURL: null, fields: null, inputFields: null, interfaces: null, @@ -428,7 +428,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__Field', - specifiedBy: null, + specifiedByURL: null, fields: [ { name: 'name', @@ -539,7 +539,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__InputValue', - specifiedBy: null, + specifiedByURL: null, fields: [ { name: 'name', @@ -628,7 +628,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__EnumValue', - specifiedBy: null, + specifiedByURL: null, fields: [ { name: 'name', @@ -691,7 +691,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__Directive', - specifiedBy: null, + specifiedByURL: null, fields: [ { name: 'name', @@ -789,7 +789,7 @@ describe('Introspection', () => { { kind: 'ENUM', name: '__DirectiveLocation', - specifiedBy: null, + specifiedByURL: null, fields: null, inputFields: null, interfaces: null, diff --git a/src/type/definition.d.ts b/src/type/definition.d.ts index 605fd97fef..685d02e4d0 100644 --- a/src/type/definition.d.ts +++ b/src/type/definition.d.ts @@ -304,7 +304,7 @@ export interface GraphQLScalarTypeExtensions { export class GraphQLScalarType { name: string; description: Maybe; - specifiedBy: Maybe; + specifiedByURL: Maybe; serialize: GraphQLScalarSerializer; parseValue: GraphQLScalarValueParser; parseLiteral: GraphQLScalarLiteralParser; @@ -315,7 +315,7 @@ export class GraphQLScalarType { constructor(config: Readonly>); toConfig(): GraphQLScalarTypeConfig & { - specifiedBy: Maybe; + specifiedByURL: Maybe; serialize: GraphQLScalarSerializer; parseValue: GraphQLScalarValueParser; parseLiteral: GraphQLScalarLiteralParser; diff --git a/src/type/definition.js b/src/type/definition.js index 68dd9bdaba..9461e79fb8 100644 --- a/src/type/definition.js +++ b/src/type/definition.js @@ -549,7 +549,7 @@ function resolveObjMapThunk(thunk: ThunkObjMap): ObjMap { export class GraphQLScalarType { name: string; description: ?string; - specifiedBy: ?string; + specifiedByURL: ?string; serialize: GraphQLScalarSerializer; parseValue: GraphQLScalarValueParser; parseLiteral: GraphQLScalarLiteralParser; @@ -561,7 +561,7 @@ export class GraphQLScalarType { const parseValue = config.parseValue ?? identityFunc; this.name = config.name; this.description = config.description; - this.specifiedBy = config.specifiedBy; + this.specifiedByURL = config.specifiedByURL; this.serialize = config.serialize ?? identityFunc; this.parseValue = parseValue; this.parseLiteral = @@ -574,9 +574,10 @@ export class GraphQLScalarType { devAssert(typeof config.name === 'string', 'Must provide name.'); devAssert( - config.specifiedBy == null || typeof config.specifiedBy === 'string', - `${this.name} must provide "specifiedBy" as a string, ` + - `but got: ${inspect(config.specifiedBy)}.`, + config.specifiedByURL == null || + typeof config.specifiedByURL === 'string', + `${this.name} must provide "specifiedByURL" as a string, ` + + `but got: ${inspect(config.specifiedByURL)}.`, ); devAssert( @@ -597,7 +598,7 @@ export class GraphQLScalarType { return { name: this.name, description: this.description, - specifiedBy: this.specifiedBy, + specifiedByURL: this.specifiedByURL, serialize: this.serialize, parseValue: this.parseValue, parseLiteral: this.parseLiteral, @@ -637,7 +638,7 @@ export type GraphQLScalarLiteralParser = ( export type GraphQLScalarTypeConfig = {| name: string, description?: ?string, - specifiedBy?: ?string, + specifiedByURL?: ?string, // Serializes an internal value to include in a response. serialize?: GraphQLScalarSerializer, // Parses an externally provided value to use as an input. diff --git a/src/type/introspection.js b/src/type/introspection.js index fd46ad4e10..f0bce5838a 100644 --- a/src/type/introspection.js +++ b/src/type/introspection.js @@ -196,7 +196,7 @@ export const __DirectiveLocation: GraphQLEnumType = new GraphQLEnumType({ export const __Type: GraphQLObjectType = new GraphQLObjectType({ name: '__Type', description: - 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedBy`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.', + 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.', fields: () => ({ kind: { @@ -241,10 +241,10 @@ export const __Type: GraphQLObjectType = new GraphQLObjectType({ resolve: (type) => type.description !== undefined ? type.description : undefined, }, - specifiedBy: { + specifiedByURL: { type: GraphQLString, resolve: (obj) => - obj.specifiedBy !== undefined ? obj.specifiedBy : undefined, + obj.specifiedByURL !== undefined ? obj.specifiedByURL : undefined, }, fields: { type: new GraphQLList(new GraphQLNonNull(__Field)), diff --git a/src/utilities/__tests__/buildASTSchema-test.js b/src/utilities/__tests__/buildASTSchema-test.js index 5f45261c70..4e3ca524d6 100644 --- a/src/utilities/__tests__/buildASTSchema-test.js +++ b/src/utilities/__tests__/buildASTSchema-test.js @@ -707,7 +707,7 @@ describe('Schema Builder', () => { const schema = buildSchema(sdl); expect(schema.getType('Foo')).to.include({ - specifiedBy: 'https://example.com/foo_spec', + specifiedByURL: 'https://example.com/foo_spec', }); }); diff --git a/src/utilities/__tests__/extendSchema-test.js b/src/utilities/__tests__/extendSchema-test.js index 8c0b5b3322..cd26bcaf7d 100644 --- a/src/utilities/__tests__/extendSchema-test.js +++ b/src/utilities/__tests__/extendSchema-test.js @@ -315,7 +315,7 @@ describe('extendSchema', () => { const extendedSchema = extendSchema(schema, parse(extensionSDL)); const foo = assertScalarType(extendedSchema.getType('Foo')); - expect(foo.specifiedBy).to.equal('https://example.com/foo_spec'); + expect(foo.specifiedByURL).to.equal('https://example.com/foo_spec'); expect(validateSchema(extendedSchema)).to.deep.equal([]); expectExtensionASTNodes(foo).to.equal(extensionSDL); diff --git a/src/utilities/__tests__/getIntrospectionQuery-test.js b/src/utilities/__tests__/getIntrospectionQuery-test.js index 2ded7c37c0..f57dec0236 100644 --- a/src/utilities/__tests__/getIntrospectionQuery-test.js +++ b/src/utilities/__tests__/getIntrospectionQuery-test.js @@ -64,12 +64,14 @@ describe('getIntrospectionQuery', () => { }); it('include "specifiedBy" field', () => { - expectIntrospectionQuery().toNotMatch('specifiedBy'); + expectIntrospectionQuery().toNotMatch('specifiedByURL'); - expectIntrospectionQuery({ specifiedByUrl: true }).toMatch('specifiedBy'); + expectIntrospectionQuery({ specifiedByUrl: true }).toMatch( + 'specifiedByURL', + ); expectIntrospectionQuery({ specifiedByUrl: false }).toNotMatch( - 'specifiedBy', + 'specifiedByURL', ); }); diff --git a/src/utilities/__tests__/printSchema-test.js b/src/utilities/__tests__/printSchema-test.js index ebcb8898c7..a649859511 100644 --- a/src/utilities/__tests__/printSchema-test.js +++ b/src/utilities/__tests__/printSchema-test.js @@ -495,10 +495,10 @@ describe('Type System Printer', () => { `); }); - it('Custom Scalar with specifiedBy', () => { + it('Custom Scalar with specifiedByURL', () => { const FooType = new GraphQLScalarType({ name: 'Foo', - specifiedBy: 'https://example.com/foo_spec', + specifiedByURL: 'https://example.com/foo_spec', }); const schema = new GraphQLSchema({ types: [FooType] }); @@ -670,13 +670,13 @@ describe('Type System Printer', () => { """ The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the \`__TypeKind\` enum. - Depending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional \`specifiedBy\`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types. + Depending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional \`specifiedByURL\`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types. """ type __Type { kind: __TypeKind! name: String description: String - specifiedBy: String + specifiedByURL: String fields(includeDeprecated: Boolean = false): [__Field!] interfaces: [__Type!] possibleTypes: [__Type!] diff --git a/src/utilities/buildClientSchema.js b/src/utilities/buildClientSchema.js index abfcb8a019..487ee6d16e 100644 --- a/src/utilities/buildClientSchema.js +++ b/src/utilities/buildClientSchema.js @@ -201,7 +201,7 @@ export function buildClientSchema( return new GraphQLScalarType({ name: scalarIntrospection.name, description: scalarIntrospection.description, - specifiedBy: scalarIntrospection.specifiedBy, + specifiedByURL: scalarIntrospection.specifiedByURL, }); } diff --git a/src/utilities/extendSchema.js b/src/utilities/extendSchema.js index 3e2e6bf26f..71be143ca8 100644 --- a/src/utilities/extendSchema.js +++ b/src/utilities/extendSchema.js @@ -310,14 +310,14 @@ export function extendSchemaImpl( const config = type.toConfig(); const extensions = typeExtensionsMap[config.name] ?? []; - let specifiedBy = config.specifiedBy; + let specifiedByURL = config.specifiedByURL; for (const extensionNode of extensions) { - specifiedBy = getSpecifiedBy(extensionNode) ?? specifiedBy; + specifiedByURL = getSpecifiedByURL(extensionNode) ?? specifiedByURL; } return new GraphQLScalarType({ ...config, - specifiedBy, + specifiedByURL, extensionASTNodes: config.extensionASTNodes.concat(extensions), }); } @@ -655,7 +655,7 @@ export function extendSchemaImpl( return new GraphQLScalarType({ name, description: astNode.description?.value, - specifiedBy: getSpecifiedBy(astNode), + specifiedByURL: getSpecifiedByURL(astNode), astNode, extensionASTNodes, }); @@ -702,9 +702,9 @@ function getDeprecationReason( } /** - * Given a scalar node, returns the string value for the specifiedBy. + * Given a scalar node, returns the string value for the specifiedByURL. */ -function getSpecifiedBy( +function getSpecifiedByURL( node: ScalarTypeDefinitionNode | ScalarTypeExtensionNode, ): ?string { const specifiedBy = getDirectiveValues(GraphQLSpecifiedByDirective, node); diff --git a/src/utilities/getIntrospectionQuery.d.ts b/src/utilities/getIntrospectionQuery.d.ts index 49745cb0aa..b34425b456 100644 --- a/src/utilities/getIntrospectionQuery.d.ts +++ b/src/utilities/getIntrospectionQuery.d.ts @@ -7,7 +7,7 @@ export interface IntrospectionOptions { // Default: true descriptions?: boolean; - // Whether to include `specifiedBy` in the introspection result. + // Whether to include `specifiedByURL` in the introspection result. // Default: false specifiedByUrl?: boolean; @@ -67,7 +67,7 @@ export interface IntrospectionScalarType { readonly kind: 'SCALAR'; readonly name: string; readonly description?: Maybe; - readonly specifiedBy?: Maybe; + readonly specifiedByURL?: Maybe; } export interface IntrospectionObjectType { diff --git a/src/utilities/getIntrospectionQuery.js b/src/utilities/getIntrospectionQuery.js index d08285ebec..888f964ff8 100644 --- a/src/utilities/getIntrospectionQuery.js +++ b/src/utilities/getIntrospectionQuery.js @@ -33,7 +33,9 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string { }; const descriptions = optionsWithDefault.descriptions ? 'description' : ''; - const specifiedByUrl = optionsWithDefault.specifiedByUrl ? 'specifiedBy' : ''; + const specifiedByUrl = optionsWithDefault.specifiedByUrl + ? 'specifiedByURL' + : ''; const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable ? 'isRepeatable' : ''; @@ -182,7 +184,7 @@ export type IntrospectionScalarType = {| +kind: 'SCALAR', +name: string, +description?: ?string, - +specifiedBy?: ?string, + +specifiedByURL?: ?string, |}; export type IntrospectionObjectType = {| diff --git a/src/utilities/printSchema.js b/src/utilities/printSchema.js index 36431d2bd7..f4b05627fb 100644 --- a/src/utilities/printSchema.js +++ b/src/utilities/printSchema.js @@ -150,7 +150,7 @@ export function printType(type: GraphQLNamedType): string { function printScalar(type: GraphQLScalarType): string { return ( - printDescription(type) + `scalar ${type.name}` + printSpecifiedBy(type) + printDescription(type) + `scalar ${type.name}` + printSpecifiedByURL(type) ); } @@ -288,15 +288,15 @@ function printDeprecated(reason: ?string): string { return ' @deprecated'; } -function printSpecifiedBy(scalar: GraphQLScalarType): string { - if (scalar.specifiedBy == null) { +function printSpecifiedByURL(scalar: GraphQLScalarType): string { + if (scalar.specifiedByURL == null) { return ''; } - const url = scalar.specifiedBy; + const url = scalar.specifiedByURL; const urlAST = astFromValue(url, GraphQLString); invariant( urlAST, - 'Unexpected null value returned from `astFromValue` for specifiedByUrl', + 'Unexpected null value returned from `astFromValue` for specifiedByURL', ); return ' @specifiedBy(url: ' + print(urlAST) + ')'; }