Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes "ctx.data" and "ctx.errors" input types compatible with "ExecutionResult" of "graphql" #542

Merged
merged 2 commits into from
Jan 18, 2021

Conversation

kettanaito
Copy link
Member

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 26885dd:

Sandbox Source
MSW React Configuration

@kettanaito
Copy link
Member Author

Hey, @ericbiewener. This pull request should fix the issue you've described.

Could you please check if these changes work for you? You can use the Codesandbox preview project above to experiment directly in the sandbox environment or install this pull request in your project.

Surprisingly, there was no need to change ctx.data, as it's never typed as undefined:

// Type definitions of the "graphql" package
export interface ExecutionResult<
  TData = { [key: string]: any },
  TExtensions = { [key: string]: any }
> {
  errors?: ReadonlyArray<GraphQLError>;
  // TS_SPECIFIC: TData. Motivation: https://github.com/graphql/graphql-js/pull/2490#issuecomment-639154229
  data?: TData | null;
  extensions?: TExtensions;
}

@kettanaito
Copy link
Member Author

Hey, @timdeschryver 👋 Sorry for troubling you. May I ask you for a quick review of these changes? Thanks!

Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM, I think we already had fixed the issue with ctx.data because I also wasn't able to reproduce that.

@kettanaito kettanaito merged commit b99be78 into master Jan 18, 2021
@kettanaito kettanaito deleted the 522-graphql-types-compatibility branch January 18, 2021 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ctx.data() and ctx.error() types are incompatible with graphql package ExecutionResult result type
2 participants