This example shows how to implement a GraphQL server with an email-password-based authentication workflow and authentication rules, based on Prisma, graphql-yoga, graphql-shield & GraphQL Nexus.
git clone https://github.com/goodok21/prisma2-upload-files
cd prisma2-upload-files
yarn
yarn start
...and open your browser http://localhost:4000
mutation SignUp {
signup(
name: "Name"
email: "test@test.ru"
password: "password"
) {
user {
id
name
}
token
}
}
mutation Auth {
login(
email: "emmx@mail.ru",
password:"password"
) {
user {
id
name
}
token
}
}
# Set "Authorization: Bearer <token>" header in playground
query me {
me {
id
name
email
posts {
id
}
}
}
mutation publishPost {
publish (
id: "ck0mjbvzb0002ljpj72ygcuhd"
) {
id
}
}
mutation createPost {
createDraft(
title: "Title"
content: "Content"
) {
id
published
author {
id
name
email
}
}
}
To upload file use cURL:
curl localhost:4000/ \
-F operations='{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id } }", "variables": { "file": null } }' \
-F map='{ "0": ["variables.file"] }' \
-F 0=@file.png