This is the repository for the morning workshop at AmsterdamJS
See the end of this README to get a 25% discount on your GraphQL Europe ticket
This git repository contains several branches that correspond to the "steps" to be performed throughout the workshops. The master
branch contains the final version of the code.
git clone [email protected]:nikolasburk/amsjs-workshop.git
cd amsjs-workshop
npm install -g prisma
prisma deploy
Note: When running
prisma deploy
, the Prisma CLI prompts you to select a Prisma server to which the Prisma service should be deployed. Select the Demo server to deploy to Prisma Cloud or setup your own Prisma server locally with Docker. The endpoint that's then printed by the CLI needs to be pasted intoindex.js
where Prisma is instantied.
node src/index.js
npm install -g graphql-cli
graphql playground
The Playground now allows to work with both GraphQL APIs side-by-side. It receives its information about the corresponding endpoints and schemas from the configuration in .graphqlconfig.yml
:
app
: The application layer built with graphql-yoga
prisma
The database layer configured with PrismaIn the following queries/mutation,
__POST_ID__
is a placeholder that needs to be replaced with theid
of an actualPost
item in your database.
graphql-yoga
)post(id: "__POST_ID__") {
id
title
content
published
}
mutation {
createDraft(
title: "How to GraphQL"
content: "Learn best practices all around developing GraphQL APIs"
) {
id
published
}
}
mutation {
publish(id: "__POST_ID__") {
id
published
}
}
mutation {
deletePost(id: "__POST_ID__") {
id
title
content
published
}
}
query {
posts(where: {
title_contains: "QL"
}) {
id
title
content
published
}
}
query {
post(where: {
id: "__POST_ID__"
}) {
id
title
content
published
}
}
mutation {
updatePost(
where: {
id: "__POST_ID__"
}
data: {
published: true
}
) {
id
title
content
published
}
}
mutation {
deletePost(where: {
id: "__POST_ID__"
}) {
id
title
content
published
}
}
The GraphQL server in this repository is build upon the following technologies:
graphql-yoga
: A GraphQL server library based on Express.js. It features out-of-the-box support for GraphQL Playgrounds as well as realtime GraphQL subscriptions.Note: When using Docker to deploy Prisma locally, the Prisma API is backed by a local MySQL database. If you're using Prisma Cloud, your Prisma API is running against an instance of AWS Aurora.
Get your tickets for GraphQL Europe here. As a special for workshop attendees, you can use this promo code to get a 25% discount on your ticket: amsmjs