This example shows how to implement a GraphQL server with TypeScript based on Photon JS, graphql-yoga and GraphQL Nexus.
To run the example, you need the Prisma 2 CLI:
npm install -g prisma2
Install Node dependencies:
npm install
cp .env.example .env
Run the following command to generate Photon JS:
prisma2 generate
Now you can seed your database using the seed
script from package.json
:
npm run seed
Launch your GraphQL server with this command:
npm run start
Navigate to http://localhost:4000 in your browser to explore the API of your GraphQL server in a GraphQL Playground.
The schema that specifies the API operations of your GraphQL server is defined in ./src/schema.graphql
. Below are a number of operations that you can send to the API using the GraphQL Playground.
Feel free to adjust any operation by adding or removing fields. The GraphQL Playground helps you with its auto-completion and query validation features.
To make changes to the GraphQL schema, you need to manipulate the Query
and Mutation
types that are defined in index.ts
.
Note that the start
script also starts a development server that automatically updates your schema every time you save a file. This way, the auto-generated GraphQL schema updates whenever you make changes in to the Query
or Mutation
types inside your TypeScript code.
- Read the Prisma 2 announcement
- Check out the Prisma 2 docs
- Share your feedback in the
prisma2-preview
channel on the Prisma Slack