diff --git a/docs/APIReference-TypeSystem.md b/docs/APIReference-TypeSystem.md index 8efd840eb6..5b5047c349 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; + 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 faefd625d6..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 specifiedByUrl', () => { + it('accepts a Scalar type defining specifiedByURL', () => { expect( () => new GraphQLScalarType({ name: 'SomeScalar', - specifiedByUrl: '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 specifiedByUrl with an incorrect type', () => { + it('rejects a Scalar type defining specifiedByURL with an incorrect type', () => { expect( () => new GraphQLScalarType({ name: 'SomeScalar', // $FlowExpectedError[incompatible-call] - specifiedByUrl: {}, + specifiedByURL: {}, }), ).to.throw( - 'SomeScalar must provide "specifiedByUrl" 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 2e5f261e94..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', - specifiedByUrl: null, + specifiedByURL: null, fields: [ { name: 'someField', @@ -57,7 +57,7 @@ describe('Introspection', () => { { kind: 'SCALAR', name: 'String', - specifiedByUrl: null, + specifiedByURL: null, fields: null, inputFields: null, interfaces: null, @@ -67,7 +67,7 @@ describe('Introspection', () => { { kind: 'SCALAR', name: 'Boolean', - specifiedByUrl: null, + specifiedByURL: null, fields: null, inputFields: null, interfaces: null, @@ -77,7 +77,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__Schema', - specifiedByUrl: null, + specifiedByURL: null, fields: [ { name: 'description', @@ -182,7 +182,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__Type', - specifiedByUrl: null, + specifiedByURL: null, fields: [ { name: 'kind', @@ -222,7 +222,7 @@ describe('Introspection', () => { deprecationReason: null, }, { - name: 'specifiedByUrl', + name: 'specifiedByURL', args: [], type: { kind: 'SCALAR', @@ -377,7 +377,7 @@ describe('Introspection', () => { { kind: 'ENUM', name: '__TypeKind', - specifiedByUrl: null, + specifiedByURL: null, fields: null, inputFields: null, interfaces: null, @@ -428,7 +428,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__Field', - specifiedByUrl: null, + specifiedByURL: null, fields: [ { name: 'name', @@ -539,7 +539,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__InputValue', - specifiedByUrl: null, + specifiedByURL: null, fields: [ { name: 'name', @@ -628,7 +628,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__EnumValue', - specifiedByUrl: null, + specifiedByURL: null, fields: [ { name: 'name', @@ -691,7 +691,7 @@ describe('Introspection', () => { { kind: 'OBJECT', name: '__Directive', - specifiedByUrl: null, + specifiedByURL: null, fields: [ { name: 'name', @@ -789,7 +789,7 @@ describe('Introspection', () => { { kind: 'ENUM', name: '__DirectiveLocation', - specifiedByUrl: null, + specifiedByURL: null, fields: null, inputFields: null, interfaces: null, diff --git a/src/type/definition.d.ts b/src/type/definition.d.ts index 50ee968b03..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; - specifiedByUrl: Maybe; + specifiedByURL: Maybe; serialize: GraphQLScalarSerializer; parseValue: GraphQLScalarValueParser; parseLiteral: GraphQLScalarLiteralParser; @@ -315,7 +315,7 @@ export class GraphQLScalarType { constructor(config: Readonly>); toConfig(): GraphQLScalarTypeConfig & { - specifiedByUrl: Maybe; + specifiedByURL: 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..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; - specifiedByUrl: ?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.specifiedByUrl = config.specifiedByUrl; + this.specifiedByURL = config.specifiedByURL; this.serialize = config.serialize ?? identityFunc; this.parseValue = parseValue; this.parseLiteral = @@ -574,10 +574,10 @@ 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.specifiedByURL == null || + typeof config.specifiedByURL === 'string', + `${this.name} must provide "specifiedByURL" as a string, ` + + `but got: ${inspect(config.specifiedByURL)}.`, ); devAssert( @@ -598,7 +598,7 @@ export class GraphQLScalarType { return { name: this.name, description: this.description, - specifiedByUrl: this.specifiedByUrl, + specifiedByURL: this.specifiedByURL, serialize: this.serialize, parseValue: this.parseValue, parseLiteral: this.parseLiteral, @@ -638,7 +638,7 @@ export type GraphQLScalarLiteralParser = ( export type GraphQLScalarTypeConfig = {| name: string, description?: ?string, - specifiedByUrl?: ?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 826fb58aa8..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 `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 `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, }, - specifiedByUrl: { + specifiedByURL: { type: GraphQLString, resolve: (obj) => - obj.specifiedByUrl !== undefined ? obj.specifiedByUrl : 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 a315a08422..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({ - specifiedByUrl: '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 7f358ade6e..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.specifiedByUrl).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 3f0c36298f..f57dec0236 100644 --- a/src/utilities/__tests__/getIntrospectionQuery-test.js +++ b/src/utilities/__tests__/getIntrospectionQuery-test.js @@ -63,15 +63,15 @@ describe('getIntrospectionQuery', () => { }).toNotMatch('description'); }); - it('include "specifiedByUrl" field', () => { - expectIntrospectionQuery().toNotMatch('specifiedByUrl'); + it('include "specifiedBy" field', () => { + expectIntrospectionQuery().toNotMatch('specifiedByURL'); expectIntrospectionQuery({ specifiedByUrl: true }).toMatch( - 'specifiedByUrl', + 'specifiedByURL', ); expectIntrospectionQuery({ specifiedByUrl: false }).toNotMatch( - 'specifiedByUrl', + 'specifiedByURL', ); }); diff --git a/src/utilities/__tests__/printSchema-test.js b/src/utilities/__tests__/printSchema-test.js index cdd4ca574c..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 specifiedByUrl', () => { + it('Custom Scalar with specifiedByURL', () => { const FooType = new GraphQLScalarType({ name: 'Foo', - specifiedByUrl: '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 \`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 \`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 - specifiedByUrl: 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 dd03316a45..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, - specifiedByUrl: scalarIntrospection.specifiedByUrl, + specifiedByURL: scalarIntrospection.specifiedByURL, }); } diff --git a/src/utilities/extendSchema.js b/src/utilities/extendSchema.js index ba79e9645f..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 specifiedByUrl = config.specifiedByUrl; + let specifiedByURL = config.specifiedByURL; for (const extensionNode of extensions) { - specifiedByUrl = getSpecifiedByUrl(extensionNode) ?? specifiedByUrl; + specifiedByURL = getSpecifiedByURL(extensionNode) ?? specifiedByURL; } return new GraphQLScalarType({ ...config, - specifiedByUrl, + specifiedByURL, extensionASTNodes: config.extensionASTNodes.concat(extensions), }); } @@ -655,7 +655,7 @@ export function extendSchemaImpl( return new GraphQLScalarType({ name, description: astNode.description?.value, - specifiedByUrl: getSpecifiedByUrl(astNode), + specifiedByURL: getSpecifiedByURL(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 specifiedByURL. */ -function getSpecifiedByUrl( +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 fd550ad36c..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 `specifiedByUrl` 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 specifiedByUrl?: Maybe; + readonly specifiedByURL?: Maybe; } export interface IntrospectionObjectType { diff --git a/src/utilities/getIntrospectionQuery.js b/src/utilities/getIntrospectionQuery.js index 1c9abb4204..888f964ff8 100644 --- a/src/utilities/getIntrospectionQuery.js +++ b/src/utilities/getIntrospectionQuery.js @@ -34,7 +34,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string { const descriptions = optionsWithDefault.descriptions ? 'description' : ''; const specifiedByUrl = optionsWithDefault.specifiedByUrl - ? 'specifiedByUrl' + ? 'specifiedByURL' : ''; const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable ? 'isRepeatable' @@ -184,7 +184,7 @@ export type IntrospectionScalarType = {| +kind: 'SCALAR', +name: string, +description?: ?string, - +specifiedByUrl?: ?string, + +specifiedByURL?: ?string, |}; export type IntrospectionObjectType = {| diff --git a/src/utilities/printSchema.js b/src/utilities/printSchema.js index f2a4d15226..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}` + printSpecifiedByUrl(type) + printDescription(type) + `scalar ${type.name}` + printSpecifiedByURL(type) ); } @@ -288,15 +288,15 @@ function printDeprecated(reason: ?string): string { return ' @deprecated'; } -function printSpecifiedByUrl(scalar: GraphQLScalarType): string { - if (scalar.specifiedByUrl == null) { +function printSpecifiedByURL(scalar: GraphQLScalarType): string { + if (scalar.specifiedByURL == null) { return ''; } - const url = scalar.specifiedByUrl; + 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) + ')'; }