Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: graphql/graphql-js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v14.5.0
Choose a base ref
...
head repository: graphql/graphql-js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v14.5.1
Choose a head ref
  • 8 commits
  • 27 files changed
  • 2 contributors

Commits on Aug 22, 2019

  1. Sync tstypes/errors with flow

    Jackson Kearl authored and IvanGoncharov committed Aug 22, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    IvanGoncharov Ivan Goncharov
    Copy the full SHA
    d84cfca View commit details
  2. Add .d.ts comments to flow

    Jackson Kearl authored and IvanGoncharov committed Aug 22, 2019
    Copy the full SHA
    37161b2 View commit details

Commits on Aug 23, 2019

  1. Sync execution TS definitions with Flow.

    Specifically:
    Create jsutils/Path.d.ts and pull some utility funcs out to there
    Add typeResolver options
    Jackson Kearl authored and IvanGoncharov committed Aug 23, 2019
    2
    Copy the full SHA
    7d9ad14 View commit details
  2. Sync subscription TS defintions with Flow

    Jackson Kearl authored and IvanGoncharov committed Aug 23, 2019
    Copy the full SHA
    49f86be View commit details
  3. Sync language TS definitions with Flow (#2107)

    * Sync language TS definitions with Flow
    
    * [] => never[], as empty tuple is invalid in TS@2
    Jackson Kearl authored and IvanGoncharov committed Aug 23, 2019
    Copy the full SHA
    9366d6d View commit details
  4. Copy the full SHA
    0c3bd82 View commit details
  5. Update deps (#2112)

    IvanGoncharov authored Aug 23, 2019
    Copy the full SHA
    1ea5b34 View commit details
  6. v14.5.1

    IvanGoncharov committed Aug 23, 2019
    Copy the full SHA
    f29be82 View commit details
4 changes: 2 additions & 2 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ untyped-type-import=error
nonstrict-import=off
untyped-import=off
unclear-type=off
deprecated-type=error
deprecated-type=off
deprecated-utility=error
dynamic-export=off
unsafe-getters-setters=error
@@ -38,4 +38,4 @@ suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$DisableFlowOnNegativeTest

[version]
^0.105.0
^0.106.0
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql",
"version": "14.5.0",
"version": "14.5.1",
"description": "A Query Language and Runtime which can target any service.",
"license": "MIT",
"private": true,
@@ -51,10 +51,10 @@
"@babel/register": "7.5.5",
"babel-eslint": "10.0.2",
"chai": "4.2.0",
"dtslint": "^0.8.0",
"dtslint": "^0.9.2",
"eslint": "5.16.0",
"eslint-plugin-flowtype": "3.12.1",
"flow-bin": "0.105.2",
"flow-bin": "0.106.0",
"mocha": "6.2.0",
"nyc": "14.1.1",
"prettier": "1.18.2"
22 changes: 22 additions & 0 deletions src/error/formatError.js
Original file line number Diff line number Diff line change
@@ -22,9 +22,31 @@ export function formatError(error: GraphQLError): GraphQLFormattedError {
: { message, locations, path };
}

/**
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
*/
export type GraphQLFormattedError = {|
/**
* A short, human-readable summary of the problem that **SHOULD NOT** change
* from occurrence to occurrence of the problem, except for purposes of
* localization.
*/
+message: string,
/**
* If an error can be associated to a particular point in the requested
* GraphQL document, it should contain a list of locations.
*/
+locations: $ReadOnlyArray<SourceLocation> | void,
/**
* If an error can be associated to a particular field in the GraphQL result,
* it _must_ contain an entry with the key `path` that details the path of
* the response field which experienced the error. This allows clients to
* identify whether a null result is intentional or caused by a runtime error.
*/
+path: $ReadOnlyArray<string | number> | void,
/**
* Reserved for implementors to extend the protocol however they see fit,
* and hence there are no additional restrictions on its contents.
*/
+extensions?: { [key: string]: mixed, ... },
|};
3 changes: 0 additions & 3 deletions src/type/definition.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// @flow strict

// FIXME
// flowlint deprecated-type:off

import objectEntries from '../polyfills/objectEntries';

import inspect from '../jsutils/inspect';
4 changes: 2 additions & 2 deletions src/version.js
Original file line number Diff line number Diff line change
@@ -8,14 +8,14 @@
/**
* A string containing the version of the GraphQL.js library
*/
export const version = '14.5.0';
export const version = '14.5.1';

/**
* An object containing the components of the GraphQL.js version string
*/
export const versionInfo = Object.freeze({
major: 14,
minor: 5,
patch: 0,
patch: 1,
preReleaseTag: null,
});
33 changes: 21 additions & 12 deletions tstypes/error/GraphQLError.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Maybe from '../tsutils/Maybe';
import { getLocation } from '../language';

import { ASTNode } from '../language/ast';
import { Source } from '../language/source';
import { SourceLocation } from '../language/location';
import { SourceLocation, getLocation } from '../language/location';

/**
* A GraphQLError describes an Error found during the parse, validate, or
@@ -11,6 +11,16 @@ import { SourceLocation } from '../language/location';
* GraphQL document and/or execution result that correspond to the Error.
*/
export class GraphQLError extends Error {
constructor(
message: string,
nodes?: ReadonlyArray<ASTNode> | ASTNode | undefined,
source?: Maybe<Source>,
positions?: Maybe<ReadonlyArray<number>>,
path?: Maybe<ReadonlyArray<string | number>>,
originalError?: Maybe<Error>,
extensions?: Maybe<{ [key: string]: any }>,
);

/**
* A message describing the Error for debugging purposes.
*
@@ -47,6 +57,9 @@ export class GraphQLError extends Error {

/**
* The source GraphQL document corresponding to this error.
*
* Note that if this Error represents more than one node, the source may not
* represent nodes after the first node.
*/
readonly source: Source | undefined;

@@ -65,14 +78,10 @@ export class GraphQLError extends Error {
* Extension fields to add to the formatted error.
*/
readonly extensions: { [key: string]: any } | undefined;

constructor(
message: string,
nodes?: ReadonlyArray<ASTNode> | ASTNode | undefined,
source?: Maybe<Source>,
positions?: Maybe<ReadonlyArray<number>>,
path?: Maybe<ReadonlyArray<string | number>>,
originalError?: Maybe<Error>,
extensions?: Maybe<{ [key: string]: any }>,
);
}

/**
* Prints a GraphQLError to a string, representing useful location information
* about the error's position in the source.
*/
export function printError(error: GraphQLError): string;
2 changes: 1 addition & 1 deletion tstypes/error/formatError.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GraphQLError } from './GraphQLError';
import { SourceLocation } from '../language/location';
import { GraphQLError } from './GraphQLError';

/**
* Given a GraphQLError, format it according to the rules described by the
3 changes: 1 addition & 2 deletions tstypes/error/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export { GraphQLError } from './GraphQLError';
export { GraphQLError, printError } from './GraphQLError';
export { syntaxError } from './syntaxError';
export { locatedError } from './locatedError';
export { printError } from './printError';
export { formatError, GraphQLFormattedError } from './formatError';
2 changes: 1 addition & 1 deletion tstypes/error/locatedError.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GraphQLError } from './GraphQLError';
import { ASTNode } from '../language/ast';
import { GraphQLError } from './GraphQLError';

/**
* Given an arbitrary Error, presumably thrown while attempting to execute a
7 changes: 0 additions & 7 deletions tstypes/error/printError.d.ts

This file was deleted.

59 changes: 30 additions & 29 deletions tstypes/execution/execute.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import Maybe from '../tsutils/Maybe';
import { PromiseOrValue } from '../jsutils/PromiseOrValue';
import { Path, addPath, pathToArray } from '../jsutils/Path';

import { GraphQLError, locatedError } from '../error';
import { GraphQLSchema } from '../type/schema';
import {
GraphQLField,
GraphQLFieldResolver,
ResponsePath,
GraphQLObjectType,
GraphQLResolveInfo,
} from '../type/definition';
import {
DirectiveNode,
DocumentNode,
@@ -17,7 +12,14 @@ import {
InlineFragmentNode,
FragmentDefinitionNode,
} from '../language/ast';
import { PromiseOrValue } from '../jsutils/PromiseOrValue';
import { GraphQLSchema } from '../type/schema';
import {
GraphQLField,
GraphQLFieldResolver,
GraphQLResolveInfo,
GraphQLTypeResolver,
GraphQLObjectType,
} from '../type/definition';

/**
* Data that must be available at all points during query execution.
@@ -46,9 +48,10 @@ export interface ExecutionResultDataDefault {
* - `errors` is included when any errors occurred as a non-empty array.
* - `data` is the result of a successful execution of the query.
*/
// TS_SPECIFIC: TData and ExecutionResultDataDefault
export interface ExecutionResult<TData = ExecutionResultDataDefault> {
errors?: ReadonlyArray<GraphQLError>;
data?: TData;
data?: TData | null;
}

export type ExecutionArgs = {
@@ -59,6 +62,7 @@ export type ExecutionArgs = {
variableValues?: Maybe<{ [key: string]: any }>;
operationName?: Maybe<string>;
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
};

/**
@@ -84,26 +88,9 @@ export function execute<TData = ExecutionResultDataDefault>(
variableValues?: Maybe<{ [key: string]: any }>,
operationName?: Maybe<string>,
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>,
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>,
): PromiseOrValue<ExecutionResult<TData>>;

/**
* Given a ResponsePath (found in the `path` entry in the information provided
* as the last argument to a field resolver), return an Array of the path keys.
*/
export function responsePathAsArray(
path: ResponsePath,
): ReadonlyArray<string | number>;

/**
* Given a ResponsePath and a key, return a new ResponsePath containing the
* new key.
*/
export function addPath(
prev: ResponsePath | undefined,
key: string | number,
): { prev: ResponsePath | undefined; key: string | number };

/**
* Essential assertions before executing to provide developer feedback for
* improper use of the GraphQL library.
@@ -128,6 +115,7 @@ export function buildExecutionContext(
rawVariableValues: Maybe<{ [key: string]: any }>,
operationName: Maybe<string>,
fieldResolver: Maybe<GraphQLFieldResolver<any, any>>,
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>,
): ReadonlyArray<GraphQLError> | ExecutionContext;

/**
@@ -151,11 +139,12 @@ export function buildResolveInfo(
fieldDef: GraphQLField<any, any>,
fieldNodes: ReadonlyArray<FieldNode>,
parentType: GraphQLObjectType,
path: ResponsePath,
path: Path,
): GraphQLResolveInfo;

// Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
// function. Returns the result of resolveFn or the abrupt-return Error object.
// TS_SPECIFIC: TSource
export function resolveFieldValueOrError<TSource>(
exeContext: ExecutionContext,
fieldDef: GraphQLField<TSource, any>,
@@ -165,6 +154,18 @@ export function resolveFieldValueOrError<TSource>(
info: GraphQLResolveInfo,
): Error | any;

/**
* If a resolveType function is not given, then a default resolve behavior is
* used which attempts two strategies:
*
* First, See if the provided value has a `__typename` field defined, if so, use
* that value as name of the resolved type.
*
* Otherwise, test each possible type for the abstract type by calling
* isTypeOf for the object being coerced, returning the first type that matches.
*/
export const defaultTypeResolver: GraphQLTypeResolver<any, any>;

/**
* If a resolve function is not given, then a default resolve behavior is used
* which takes the property of the source object of the same name as the field
4 changes: 3 additions & 1 deletion tstypes/execution/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export { pathToArray as responsePathAsArray } from '../jsutils/Path';

export {
execute,
defaultFieldResolver,
responsePathAsArray,
defaultTypeResolver,
ExecutionArgs,
ExecutionResult,
} from './execute';
23 changes: 12 additions & 11 deletions tstypes/execution/values.d.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import Maybe from '../tsutils/Maybe';
import { GraphQLError } from '../error/GraphQLError';
import {
GraphQLInputType,
GraphQLField,
GraphQLArgument,
} from '../type/definition';
import { GraphQLDirective } from '../type/directives';
import { GraphQLSchema } from '../type/schema';
import {
FieldNode,
DirectiveNode,
VariableDefinitionNode,
} from '../language/ast';

interface CoercedVariableValues {
errors: ReadonlyArray<GraphQLError> | undefined;
coerced: { [key: string]: any } | undefined;
}
import { GraphQLDirective } from '../type/directives';
import { GraphQLSchema } from '../type/schema';
import {
GraphQLInputType,
GraphQLField,
GraphQLArgument,
} from '../type/definition';

type CoercedVariableValues =
| { errors: ReadonlyArray<GraphQLError>; coerced?: never }
| { errors?: never; coerced: { [key: string]: any } };

/**
* Prepares an object map of variableValues of the correct type based on the
@@ -31,6 +31,7 @@ export function getVariableValues(
schema: GraphQLSchema,
varDefNodes: VariableDefinitionNode[],
inputs: { [key: string]: any },
options: { maxErrors?: number },
): CoercedVariableValues;

/**
14 changes: 14 additions & 0 deletions tstypes/jsutils/Path.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export type Path = {
prev: Path | void;
key: string | number;
};

/**
* Given a Path and a key, return a new Path containing the new key.
*/
export function addPath(prev: Path | undefined, key: string | number): Path;

/**
* Given a Path, return an Array of the path keys.
*/
export function pathToArray(path: Path): Array<string | number>;
2 changes: 1 addition & 1 deletion tstypes/language/ast.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Source } from './source';
import { TokenKindEnum } from './lexer';
import { TokenKindEnum } from './tokenKind';

/**
* Contains a range of UTF-8 character offsets and token references that
14 changes: 14 additions & 0 deletions tstypes/language/blockString.d.ts
Original file line number Diff line number Diff line change
@@ -5,3 +5,17 @@
* This implements the GraphQL spec's BlockStringValue() static algorithm.
*/
export function dedentBlockStringValue(rawString: string): string;

// @internal
export function getBlockStringIndentation(lines: ReadonlyArray<string>): number;

/**
* Print a block string in the indented block form by adding a leading and
* trailing blank line. However, if a block string starts with whitespace and is
* a single-line, adding a leading blank line would strip that whitespace.
*/
export function printBlockString(
value: string,
indentation?: string,
preferMultipleLines?: boolean,
): string;
Loading