This example is an GraphQL server implementation in TypeScript using Apollo Federation, Prisma and Nexus-Schema. It uses Postgres database.
Clone this repository:
git clone [email protected]:ricardoalmeida/federation-nexus-prisma.git
Install yarn dependencies:
cd federation-nexus-prisma
yarn install
docker-compose up -d
yarn prisma:migrate
Vitrola (Service)
yarn dev
Gateway Server
yarn gateway
The GraphQL Playground is available in http://localhost:4000/graphql.
Try it out!
mutation createTrack {
createOneTrack(data: { name: "Favorite Track" }) {
id
name
}
}
mutation createPlaylist {
createOnePlaylist(data: { description: "My playlist" }) {
id
}
}
query playlists {
playlists {
id
description
tracks {
id
}
}
}
query playlist {
playlist(where: { id: 1 }) {
id
tracks {
id
}
}
}
If you use VSCode, install plugin for Prisma: https://marketplace.visualstudio.com/items?itemName=Prisma.prisma
GraphQL queries and mutations are using Postgres for an integration test validation. So make sure you have the db up and running.
yarn postgres:start
yarn test
The Gateway authenticates the user (TODO) and send proper headers to the service. The service uses graphql-shield to verify permissions.