Skip to content

Instantly share code, notes, and snippets.

@snoopdave
Last active April 19, 2023 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snoopdave/b612da40251ce9149bd3bb2b9eae0150 to your computer and use it in GitHub Desktop.
Save snoopdave/b612da40251ce9149bd3bb2b9eae0150 to your computer and use it in GitHub Desktop.
Prompt to create GraphQL Relay-Connections testing example

I want to create a Typescript project that is a example of how to test a GraphQL server and verify that the server supports the Relay-Connections specification here: https://relay.dev/graphql/connections.htm

The project should meet these requirements:

  • Contains a Jest test file as follows:
    • Before running test, Apollo Server before running the tests:
      • The server should be started as shown here: https://github.com/snoopdave/blogql/blob/main/server/src/integration.test.ts#L48
      • The server should provide:
        • A GraphQL schema that defines a User type with id, name, email address properties. The GraphQL schema should be read from a separate file called schema.graphql
        • A GraphQL query called getUsers that returns a collection of users with Relay-Connection paging, by default this query returns a maximum of 10 users at a time. Both forward and backward paging should be supported
      • When the server starts, it should create a collection of 100 random users in-memory using Faker and these users should be returned when the getUsers query is called.
      • Provide complete implementation of all GraphQL resolvers needed
    • There should also be a series of tests that verify that the getUsers query fully-conforms to the Relay-Connections specification:
  • The project should include a complete package.json file:
    • The project should use graphql@^15.0.0
    • The project's pacakge.json file should include targets for running the tests and for running the relay compiler to generate TypeScript for the GraphQL queries and types using the schema from the schema.graphql
    • The project should include Jest
    • The package.json file should define a run script that will run a GraphQL linter on the schema.graphql file, and the linter should be configured to check for Relay-Connection conformance
  • Review every import in the project and ensure there is a matching dependency for it in package.json

Next, generate a complete project by first displaying the project's directory structure and then providing the contents of each file. Try to minimize the number of files and directories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment