Skip to content

Commit

Permalink
types: Adjust prior assumptions for new graphql 14.5.x types. (#3225)
Browse files Browse the repository at this point in the history
Fix incorrect assumption that the `ExecutionResult` would never be `null`.  This is not true, and is now enforced in the typings for graphql@^14.5.4.

Additionally, while `GraphQLInputField` used to be assignable to `GraphQLArgument`, it no longer is since `description` is required on a `GraphQLArgument` while optional on `GraphQLInputField`.
  • Loading branch information
Jackson Kearl authored and abernix committed Aug 31, 2019
1 parent ff3af66 commit befe9d1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ function printArgs(args: GraphQLArgument[], indentation = '') {
);
}

function printInputValue(arg: GraphQLArgument) {
function printInputValue(arg: GraphQLInputField | GraphQLArgument) {
const defaultAST = astFromValue(arg.defaultValue, arg.type);
let argDecl = arg.name + ': ' + String(arg.type);
if (defaultAST) {
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-gateway/src/executeQueryPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function executeQueryPlan<TContext>(
errors,
};

let data: ResultMap | undefined = Object.create(null);
let data: ResultMap | undefined | null = Object.create(null);

const captureTraces = !!(
requestContext.metrics && requestContext.metrics.captureTraces
Expand Down Expand Up @@ -288,7 +288,7 @@ async function executeFetch<TContext>(
context: ExecutionContext<TContext>,
operation: OperationDefinitionNode,
variables: Record<string, any>,
): Promise<ResultMap | void> {
): Promise<ResultMap | void | null> {
const source = print(operation);
// We declare this as 'any' because it is missing url and method, which
// GraphQLRequest.http is supposed to have if it exists.
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-server-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface GraphQLRequest {
export type VariableValues = { [name: string]: any };

export interface GraphQLResponse {
data?: Record<string, any>;
data?: Record<string, any> | null;
errors?: ReadonlyArray<GraphQLFormattedError>;
extensions?: Record<string, any>;
http?: Pick<Response, 'headers'> & Partial<Pick<Mutable<Response>, 'status'>>;
Expand Down Expand Up @@ -103,7 +103,7 @@ export type GraphQLExecutor<TContext = Record<string, any>> = (
) => ValueOrPromise<GraphQLExecutionResult>;

export type GraphQLExecutionResult = {
data?: Record<string, any>;
data?: Record<string, any> | null;
errors?: ReadonlyArray<GraphQLError>;
extensions?: Record<string, any>;
};

0 comments on commit befe9d1

Please sign in to comment.