Skip to content

Commit

Permalink
Manually concat all static strings (#1921)
Browse files Browse the repository at this point in the history
Makes editing strings easier and clean resulting diffs
Plus all modern editors support wrapping of long lines.
  • Loading branch information
IvanGoncharov committed May 28, 2019
1 parent 5eecef2 commit 63cc5df
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 82 deletions.
5 changes: 1 addition & 4 deletions src/execution/__tests__/abstract-test.js
Expand Up @@ -423,10 +423,7 @@ describe('Execute: Handles execution of abstract types', () => {
errors: [
{
message:
'Abstract type FooInterface must resolve to an Object type at ' +
'runtime for field Query.foo with value "dummy", received "[]". ' +
'Either the FooInterface type should provide a "resolveType" ' +
'function or each possible type should provide an "isTypeOf" function.',
'Abstract type FooInterface must resolve to an Object type at runtime for field Query.foo with value "dummy", received "[]". Either the FooInterface type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.',
locations: [{ line: 1, column: 3 }],
path: ['foo'],
},
Expand Down
4 changes: 1 addition & 3 deletions src/execution/execute.js
Expand Up @@ -288,9 +288,7 @@ export function assertValidExecutionArguments(
// Variables, if provided, must be an object.
invariant(
!rawVariableValues || typeof rawVariableValues === 'object',
'Variables must be provided as an Object where each property is a ' +
'variable value. Perhaps look to see if an unparsed JSON string ' +
'was provided.',
'Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.',
);
}

Expand Down
3 changes: 1 addition & 2 deletions src/language/__tests__/lexer-test.js
Expand Up @@ -226,8 +226,7 @@ describe('Lexer', () => {

expectSyntaxError(
"'single quotes'",
"Unexpected single quote character ('), " +
'did you mean to use a double quote (")?',
'Unexpected single quote character (\'), did you mean to use a double quote (")?',
{ line: 1, column: 1 },
);

Expand Down
5 changes: 1 addition & 4 deletions src/language/lexer.js
Expand Up @@ -364,10 +364,7 @@ function unexpectedCharacterMessage(code) {

if (code === 39) {
// '
return (
"Unexpected single quote character ('), did you mean to use " +
'a double quote (")?'
);
return 'Unexpected single quote character (\'), did you mean to use a double quote (")?';
}

return `Cannot parse the unexpected character ${printCharCode(code)}.`;
Expand Down
5 changes: 1 addition & 4 deletions src/type/__tests__/introspection-test.js
Expand Up @@ -1291,10 +1291,7 @@ describe('Introspection', () => {
schemaType: {
name: '__Schema',
description:
'A GraphQL Schema defines the capabilities of a ' +
'GraphQL server. It exposes all available types and ' +
'directives on the server, as well as the entry ' +
'points for query, mutation, and subscription operations.',
'A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.',
fields: [
{
name: 'types',
Expand Down
3 changes: 1 addition & 2 deletions src/type/definition.js
Expand Up @@ -567,8 +567,7 @@ export class GraphQLScalarType {
invariant(
typeof config.serialize === 'function',
`${this.name} must provide "serialize" function. If this custom Scalar ` +
'is also used as an input type, ensure "parseValue" and "parseLiteral" ' +
'functions are also provided.',
'is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.',
);
if (config.parseValue || config.parseLiteral) {
invariant(
Expand Down
10 changes: 3 additions & 7 deletions src/type/directives.js
Expand Up @@ -118,8 +118,7 @@ export type GraphQLDirectiveConfig = {|
export const GraphQLIncludeDirective = new GraphQLDirective({
name: 'include',
description:
'Directs the executor to include this field or fragment only when ' +
'the `if` argument is true.',
'Directs the executor to include this field or fragment only when the `if` argument is true.',
locations: [
DirectiveLocation.FIELD,
DirectiveLocation.FRAGMENT_SPREAD,
Expand All @@ -139,8 +138,7 @@ export const GraphQLIncludeDirective = new GraphQLDirective({
export const GraphQLSkipDirective = new GraphQLDirective({
name: 'skip',
description:
'Directs the executor to skip this field or fragment when the `if` ' +
'argument is true.',
'Directs the executor to skip this field or fragment when the `if` argument is true.',
locations: [
DirectiveLocation.FIELD,
DirectiveLocation.FRAGMENT_SPREAD,
Expand Down Expand Up @@ -170,9 +168,7 @@ export const GraphQLDeprecatedDirective = new GraphQLDirective({
reason: {
type: GraphQLString,
description:
'Explains why this element was deprecated, usually also including a ' +
'suggestion for how to access supported similar data. Formatted using ' +
'the Markdown syntax (as specified by [CommonMark](https://commonmark.org/).',
'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax (as specified by [CommonMark](https://commonmark.org/).',
defaultValue: DEFAULT_DEPRECATION_REASON,
},
},
Expand Down
52 changes: 13 additions & 39 deletions src/type/introspection.js
Expand Up @@ -34,9 +34,7 @@ import { DirectiveLocation } from '../language/directiveLocation';
export const __Schema = new GraphQLObjectType({
name: '__Schema',
description:
'A GraphQL Schema defines the capabilities of a GraphQL server. It ' +
'exposes all available types and directives on the server, as well as ' +
'the entry points for query, mutation, and subscription operations.',
'A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.',
fields: () => ({
types: {
description: 'A list of all types supported by this server.',
Expand All @@ -52,15 +50,13 @@ export const __Schema = new GraphQLObjectType({
},
mutationType: {
description:
'If this server supports mutation, the type that ' +
'mutation operations will be rooted at.',
'If this server supports mutation, the type that mutation operations will be rooted at.',
type: __Type,
resolve: schema => schema.getMutationType(),
},
subscriptionType: {
description:
'If this server support subscription, the type that ' +
'subscription operations will be rooted at.',
'If this server support subscription, the type that subscription operations will be rooted at.',
type: __Type,
resolve: schema => schema.getSubscriptionType(),
},
Expand All @@ -75,12 +71,7 @@ export const __Schema = new GraphQLObjectType({
export const __Directive = new GraphQLObjectType({
name: '__Directive',
description:
'A Directive provides a way to describe alternate runtime execution and ' +
'type validation behavior in a GraphQL document.' +
"\n\nIn some cases, you need to provide options to alter GraphQL's " +
'execution behavior in ways field arguments will not suffice, such as ' +
'conditionally including or skipping a field. Directives provide this by ' +
'describing additional information to the executor.',
"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.",
fields: () => ({
name: {
type: GraphQLNonNull(GraphQLString),
Expand All @@ -104,8 +95,7 @@ export const __Directive = new GraphQLObjectType({
export const __DirectiveLocation = new GraphQLEnumType({
name: '__DirectiveLocation',
description:
'A Directive can be adjacent to many parts of the GraphQL language, a ' +
'__DirectiveLocation describes one such possible adjacencies.',
'A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.',
values: {
QUERY: {
value: DirectiveLocation.QUERY,
Expand Down Expand Up @@ -189,14 +179,7 @@ export const __DirectiveLocation = new GraphQLEnumType({
export const __Type = 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 and description, 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 and description, 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: {
type: GraphQLNonNull(__TypeKind),
Expand Down Expand Up @@ -297,8 +280,7 @@ export const __Type = new GraphQLObjectType({
export const __Field = new GraphQLObjectType({
name: '__Field',
description:
'Object and Interface types are described by a list of Fields, each of ' +
'which has a name, potentially a list of arguments, and a return type.',
'Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.',
fields: () => ({
name: {
type: GraphQLNonNull(GraphQLString),
Expand Down Expand Up @@ -330,9 +312,7 @@ export const __Field = new GraphQLObjectType({
export const __InputValue = new GraphQLObjectType({
name: '__InputValue',
description:
'Arguments provided to Fields or Directives and the input fields of an ' +
'InputObject are represented as Input Values which describe their type ' +
'and optionally a default value.',
'Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.',
fields: () => ({
name: {
type: GraphQLNonNull(GraphQLString),
Expand All @@ -349,8 +329,7 @@ export const __InputValue = new GraphQLObjectType({
defaultValue: {
type: GraphQLString,
description:
'A GraphQL-formatted string representing the default value for this ' +
'input value.',
'A GraphQL-formatted string representing the default value for this input value.',
resolve(inputVal) {
const valueAST = astFromValue(inputVal.defaultValue, inputVal.type);
return valueAST ? print(valueAST) : null;
Expand All @@ -362,9 +341,7 @@ export const __InputValue = new GraphQLObjectType({
export const __EnumValue = new GraphQLObjectType({
name: '__EnumValue',
description:
'One possible value for a given Enum. Enum values are unique values, not ' +
'a placeholder for a string or numeric value. However an Enum value is ' +
'returned in a JSON response as a string.',
'One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.',
fields: () => ({
name: {
type: GraphQLNonNull(GraphQLString),
Expand Down Expand Up @@ -407,14 +384,12 @@ export const __TypeKind = new GraphQLEnumType({
OBJECT: {
value: TypeKind.OBJECT,
description:
'Indicates this type is an object. ' +
'`fields` and `interfaces` are valid fields.',
'Indicates this type is an object. `fields` and `interfaces` are valid fields.',
},
INTERFACE: {
value: TypeKind.INTERFACE,
description:
'Indicates this type is an interface. ' +
'`fields` and `possibleTypes` are valid fields.',
'Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.',
},
UNION: {
value: TypeKind.UNION,
Expand All @@ -429,8 +404,7 @@ export const __TypeKind = new GraphQLEnumType({
INPUT_OBJECT: {
value: TypeKind.INPUT_OBJECT,
description:
'Indicates this type is an input object. ' +
'`inputFields` is a valid field.',
'Indicates this type is an input object. `inputFields` is a valid field.',
},
LIST: {
value: TypeKind.LIST,
Expand Down
17 changes: 4 additions & 13 deletions src/type/scalars.js
Expand Up @@ -61,8 +61,7 @@ function coerceInt(value: mixed): number {
export const GraphQLInt = new GraphQLScalarType({
name: 'Int',
description:
'The `Int` scalar type represents non-fractional signed whole numeric ' +
'values. Int can represent values between -(2^31) and 2^31 - 1.',
'The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.',
serialize: serializeInt,
parseValue: coerceInt,
parseLiteral(ast) {
Expand Down Expand Up @@ -105,9 +104,7 @@ function coerceFloat(value: mixed): number {
export const GraphQLFloat = new GraphQLScalarType({
name: 'Float',
description:
'The `Float` scalar type represents signed double-precision fractional ' +
'values as specified by ' +
'[IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).',
'The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).',
serialize: serializeFloat,
parseValue: coerceFloat,
parseLiteral(ast) {
Expand Down Expand Up @@ -165,9 +162,7 @@ function coerceString(value: mixed): string {
export const GraphQLString = new GraphQLScalarType({
name: 'String',
description:
'The `String` scalar type represents textual data, represented as UTF-8 ' +
'character sequences. The String type is most often used by GraphQL to ' +
'represent free-form human-readable text.',
'The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.',
serialize: serializeString,
parseValue: coerceString,
parseLiteral(ast) {
Expand Down Expand Up @@ -231,11 +226,7 @@ function coerceID(value: mixed): string {
export const GraphQLID = new GraphQLScalarType({
name: 'ID',
description:
'The `ID` scalar type represents a unique identifier, often used to ' +
'refetch an object or as key for a cache. The ID type appears in a JSON ' +
'response as a String; however, it is not intended to be human-readable. ' +
'When expected as an input type, any string (such as `"4"`) or integer ' +
'(such as `4`) input value will be accepted as an ID.',
'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.',
serialize: serializeID,
parseValue: coerceID,
parseLiteral(ast) {
Expand Down
6 changes: 2 additions & 4 deletions src/utilities/buildClientSchema.js
Expand Up @@ -154,8 +154,7 @@ export function buildClientSchema(
if (!type) {
throw new Error(
`Invalid or incomplete schema, unknown type: ${typeName}. Ensure ` +
'that a full introspection query is used in order to build a ' +
'client schema.',
'that a full introspection query is used in order to build a client schema.',
);
}

Expand Down Expand Up @@ -220,8 +219,7 @@ export function buildClientSchema(
}
}
throw new Error(
'Invalid or incomplete introspection result. Ensure that a full ' +
'introspection query is used in order to build a client schema:' +
'Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema:' +
inspect(type),
);
}
Expand Down

0 comments on commit 63cc5df

Please sign in to comment.