Skip to content

Commit

Permalink
Use specifiedBy instead of specifiedByUrl (#3032)
Browse files Browse the repository at this point in the history
  • Loading branch information
Code-Hex committed Apr 20, 2021
1 parent b9fd53b commit 2d48fbb
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion docs/APIReference-TypeSystem.md
Expand Up @@ -206,7 +206,7 @@ class GraphQLScalarType<InternalType> {
type GraphQLScalarTypeConfig<InternalType> = {
name: string;
description?: ?string;
specifiedByUrl?: string;
specifiedByURL?: string;
serialize: (value: mixed) => ?InternalType;
parseValue?: (value: mixed) => ?InternalType;
parseLiteral?: (valueAST: Value) => ?InternalType;
Expand Down
10 changes: 5 additions & 5 deletions src/type/__tests__/definition-test.js
Expand Up @@ -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();
});
Expand Down Expand Up @@ -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: {}.',
);
});
});
Expand Down
24 changes: 12 additions & 12 deletions src/type/__tests__/introspection-test.js
Expand Up @@ -35,7 +35,7 @@ describe('Introspection', () => {
{
kind: 'OBJECT',
name: 'SomeObject',
specifiedByUrl: null,
specifiedByURL: null,
fields: [
{
name: 'someField',
Expand All @@ -57,7 +57,7 @@ describe('Introspection', () => {
{
kind: 'SCALAR',
name: 'String',
specifiedByUrl: null,
specifiedByURL: null,
fields: null,
inputFields: null,
interfaces: null,
Expand All @@ -67,7 +67,7 @@ describe('Introspection', () => {
{
kind: 'SCALAR',
name: 'Boolean',
specifiedByUrl: null,
specifiedByURL: null,
fields: null,
inputFields: null,
interfaces: null,
Expand All @@ -77,7 +77,7 @@ describe('Introspection', () => {
{
kind: 'OBJECT',
name: '__Schema',
specifiedByUrl: null,
specifiedByURL: null,
fields: [
{
name: 'description',
Expand Down Expand Up @@ -182,7 +182,7 @@ describe('Introspection', () => {
{
kind: 'OBJECT',
name: '__Type',
specifiedByUrl: null,
specifiedByURL: null,
fields: [
{
name: 'kind',
Expand Down Expand Up @@ -222,7 +222,7 @@ describe('Introspection', () => {
deprecationReason: null,
},
{
name: 'specifiedByUrl',
name: 'specifiedByURL',
args: [],
type: {
kind: 'SCALAR',
Expand Down Expand Up @@ -377,7 +377,7 @@ describe('Introspection', () => {
{
kind: 'ENUM',
name: '__TypeKind',
specifiedByUrl: null,
specifiedByURL: null,
fields: null,
inputFields: null,
interfaces: null,
Expand Down Expand Up @@ -428,7 +428,7 @@ describe('Introspection', () => {
{
kind: 'OBJECT',
name: '__Field',
specifiedByUrl: null,
specifiedByURL: null,
fields: [
{
name: 'name',
Expand Down Expand Up @@ -539,7 +539,7 @@ describe('Introspection', () => {
{
kind: 'OBJECT',
name: '__InputValue',
specifiedByUrl: null,
specifiedByURL: null,
fields: [
{
name: 'name',
Expand Down Expand Up @@ -628,7 +628,7 @@ describe('Introspection', () => {
{
kind: 'OBJECT',
name: '__EnumValue',
specifiedByUrl: null,
specifiedByURL: null,
fields: [
{
name: 'name',
Expand Down Expand Up @@ -691,7 +691,7 @@ describe('Introspection', () => {
{
kind: 'OBJECT',
name: '__Directive',
specifiedByUrl: null,
specifiedByURL: null,
fields: [
{
name: 'name',
Expand Down Expand Up @@ -789,7 +789,7 @@ describe('Introspection', () => {
{
kind: 'ENUM',
name: '__DirectiveLocation',
specifiedByUrl: null,
specifiedByURL: null,
fields: null,
inputFields: null,
interfaces: null,
Expand Down
6 changes: 3 additions & 3 deletions src/type/definition.d.ts
Expand Up @@ -304,7 +304,7 @@ export interface GraphQLScalarTypeExtensions {
export class GraphQLScalarType {
name: string;
description: Maybe<string>;
specifiedByUrl: Maybe<string>;
specifiedByURL: Maybe<string>;
serialize: GraphQLScalarSerializer<unknown>;
parseValue: GraphQLScalarValueParser<unknown>;
parseLiteral: GraphQLScalarLiteralParser<unknown>;
Expand All @@ -315,7 +315,7 @@ export class GraphQLScalarType {
constructor(config: Readonly<GraphQLScalarTypeConfig<unknown, unknown>>);

toConfig(): GraphQLScalarTypeConfig<unknown, unknown> & {
specifiedByUrl: Maybe<string>;
specifiedByURL: Maybe<string>;
serialize: GraphQLScalarSerializer<unknown>;
parseValue: GraphQLScalarValueParser<unknown>;
parseLiteral: GraphQLScalarLiteralParser<unknown>;
Expand All @@ -342,7 +342,7 @@ export type GraphQLScalarLiteralParser<TInternal> = (
export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
name: string;
description?: Maybe<string>;
specifiedByUrl?: Maybe<string>;
specifiedBy?: Maybe<string>;
// Serializes an internal value to include in a response.
serialize?: GraphQLScalarSerializer<TExternal>;
// Parses an externally provided value to use as an input.
Expand Down
16 changes: 8 additions & 8 deletions src/type/definition.js
Expand Up @@ -549,7 +549,7 @@ function resolveObjMapThunk<T>(thunk: ThunkObjMap<T>): ObjMap<T> {
export class GraphQLScalarType {
name: string;
description: ?string;
specifiedByUrl: ?string;
specifiedByURL: ?string;
serialize: GraphQLScalarSerializer<mixed>;
parseValue: GraphQLScalarValueParser<mixed>;
parseLiteral: GraphQLScalarLiteralParser<mixed>;
Expand All @@ -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 =
Expand All @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -638,7 +638,7 @@ export type GraphQLScalarLiteralParser<TInternal> = (
export type GraphQLScalarTypeConfig<TInternal, TExternal> = {|
name: string,
description?: ?string,
specifiedByUrl?: ?string,
specifiedByURL?: ?string,
// Serializes an internal value to include in a response.
serialize?: GraphQLScalarSerializer<TExternal>,
// Parses an externally provided value to use as an input.
Expand Down
6 changes: 3 additions & 3 deletions src/type/introspection.js
Expand Up @@ -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: {
Expand Down Expand Up @@ -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)),
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/__tests__/buildASTSchema-test.js
Expand Up @@ -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',
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/utilities/__tests__/extendSchema-test.js
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/utilities/__tests__/getIntrospectionQuery-test.js
Expand Up @@ -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',
);
});

Expand Down
8 changes: 4 additions & 4 deletions src/utilities/__tests__/printSchema-test.js
Expand Up @@ -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] });
Expand Down Expand Up @@ -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!]
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/buildClientSchema.js
Expand Up @@ -201,7 +201,7 @@ export function buildClientSchema(
return new GraphQLScalarType({
name: scalarIntrospection.name,
description: scalarIntrospection.description,
specifiedByUrl: scalarIntrospection.specifiedByUrl,
specifiedByURL: scalarIntrospection.specifiedByURL,
});
}

Expand Down
12 changes: 6 additions & 6 deletions src/utilities/extendSchema.js
Expand Up @@ -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),
});
}
Expand Down Expand Up @@ -655,7 +655,7 @@ export function extendSchemaImpl(
return new GraphQLScalarType({
name,
description: astNode.description?.value,
specifiedByUrl: getSpecifiedByUrl(astNode),
specifiedByURL: getSpecifiedByURL(astNode),
astNode,
extensionASTNodes,
});
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/getIntrospectionQuery.d.ts
Expand Up @@ -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;

Expand Down Expand Up @@ -67,7 +67,7 @@ export interface IntrospectionScalarType {
readonly kind: 'SCALAR';
readonly name: string;
readonly description?: Maybe<string>;
readonly specifiedByUrl?: Maybe<string>;
readonly specifiedByURL?: Maybe<string>;
}

export interface IntrospectionObjectType {
Expand Down

0 comments on commit 2d48fbb

Please sign in to comment.