pipenv shell
pipenv install
cd app
python manage.py runserver
- go to http://localhost:8000/graphql/
- explore the "Docs" on the right (Queries, Mutations)
- Write your first query:
GET BOOKS:
query getBooks {
books {
id
author
description
url
}
}
CREATE A NEW USER:
mutation {
createUser(email: "VALID_EMAIL", password: "VALID_PASSWORD", username: "USERNAME"){
user {
id
email
username
}
}
}
example -> createUser(email: "[email protected]", password: "1234567890", username: "test_123")
After creating a user profile, you can login
1. GET THE AUTH TOKEN
Enter your username and password you've just provided. After executing the query copy the auth token
mutation {
tokenAuth(username:"USERNAME", password: "VALID_PASSWORD") {
token
}
}
2. LOG IN
Enter your Auth Token in REQUEST HEADERS TAB
{
"Authorization": "JWT {YOUR TOKEN}"
}
3. GET INFO ABOUT THE USER YOU HAVE CREATED:
{
me {
id
username
email
}
}
mutation {
createBook(author:"cool author", description: "some desct", url: "9599", title: "titlre"){
book {
id
title
description
author
url
createdAt
}
}
}
mutation {
updateBook(bookId: 8, author:"Unknown Author"){
book{
id
author
description
}
}
}
mutation {
deleteBook(bookId: 8){
bookId
}
}
mutation {
createLike(bookId: 8) {
user {
id
username
}
}
}
query {
books {
id
title
description
likes {
id
user {
id
username
}
}
}
}
query{
books(search: "python") {
id
title
author
description
}
}