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

Add ApolloServer direct testing support via strongly typed executeOperation #144

Merged
merged 11 commits into from
May 30, 2024

Conversation

cuzzlor
Copy link
Collaborator

@cuzzlor cuzzlor commented May 29, 2024

What ?

We have been using the ApolloServer v4 instance executeOperation function to support testing GraphQL servers without using the network. You might call this a 'subcutaneous' testing approach for a GraphQL implementation.

We don't have any common helpers to assist yet in our libs, so this attempts to take the core of what helps set up testing infrastructure using this approach.

How

Before you review, please note the Also section below (lots of accompanying changes). The following changes are isolated to the ./src/testing folder

  • Add strongly typed executeOperation factory function to facilitate running operations using strong typing via TypedDocumentNode
  • Add utils to assist creating GraphQL contexts for operations
  • Add a complete working vitest example
  • Add doc

Also

The following things outside of the above changes to the to the ./src/testing folder.

commit: run ts-toolkit init, prepare for vitest

  • Run ts-toolkit across this lib to make it more consistent with others: APOLOGIES FOR ALL THE CHANGED FILES !!
  • Upgrade all packages
  • Fix a type def with latest new ApolloServer on the logging plugins
  • Update GH workflows to use NodeJS v20 and to output test results

@cuzzlor cuzzlor requested a review from staff0rd May 29, 2024 09:58
@cuzzlor cuzzlor marked this pull request as draft May 29, 2024 09:58
@cuzzlor cuzzlor requested review from robdmoore, boblat and mderriey May 29, 2024 10:03
@cuzzlor cuzzlor marked this pull request as ready for review May 29, 2024 10:09
@cuzzlor cuzzlor force-pushed the testing-support-execute-operation branch from 92c7a9b to 111ab31 Compare May 29, 2024 10:37
package.json Show resolved Hide resolved
package.json Show resolved Hide resolved
@cuzzlor cuzzlor merged commit 2e866e9 into main May 30, 2024
2 checks passed
@cuzzlor cuzzlor deleted the testing-support-execute-operation branch May 30, 2024 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants