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 calledschema.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
- A GraphQL schema that defines a
- 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 first test should verify that all 100 users can be retrieved by the Relay React client which can be used as shown here https://relay.dev/docs/getting-started/step-by-step-guide/#step-5-fetching-a-query-with-relay and should use
loadQuery
andusePreloadedQuery
fromreact-relay/hooks
- The test of the tests should verify that the cursors returned by the
getUsers
query are correct - Provide complete implementations of all tests
- The first test should verify that all 100 users can be retrieved by the Relay React client which can be used as shown here https://relay.dev/docs/getting-started/step-by-step-guide/#step-5-fetching-a-query-with-relay and should use
- Before running test, Apollo Server before running the tests:
- 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 theschema.graphql
- The project should include Jest
- The
package.json
file should define a run script that will run a GraphQL linter on theschema.graphql
file, and the linter should be configured to check for Relay-Connection conformance
- The project should use
- 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.