Skip to content

Graphql examples

Vinicius Zucatti edited this page May 3, 2023 · 1 revision

GraphQL Docs

Here are some examples of how to integrate with the GraphQL server. Add the correct tokens before making those requests

MUTATIONS

mutation SignIn

headers

Content-Type: application/json
X-CSRF-Token: 6qxhPNFVm4n08BfIqemoAhN4_rA7FS-ED5PgAbQiqGvODkKP7CKL1z66XrJ3k-dJBgGNzABdU-hFBaD4bgmjZA

body

mutation {
  signInUser(input: { email: "[email protected]", password: "test123" }){
    token,
    user{
      email
    }
  }
}

mutation CreateUser

headers

Content-Type: application/json
X-CSRF-Token: 6qxhPNFVm4n08BfIqemoAhN4_rA7FS-ED5PgAbQiqGvODkKP7CKL1z66XrJ3k-dJBgGNzABdU-hFBaD4bgmjZA

body

mutation {
  createUser(input: {email: "[email protected]", password: "test123"}) {
    user {
      id
    }
  }
}

mutation CreateProduct

headers

Content-Type: application/json
X-CSRF-Token: 6qxhPNFVm4n08BfIqemoAhN4_rA7FS-ED5PgAbQiqGvODkKP7CKL1z66XrJ3k-dJBgGNzABdU-hFBaD4bgmjZA
Bearer Token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1LCJleHAiOjE2NzYwNzk2OTJ9.3fKl0k5vdx839m7qqNK81QB2Q_vV2puup9y3UxbfUW0

body

mutation CreateProduct {
  createProduct(
    input: {
      priceInDiamonds: 10
      name: "torta"
      shortDescription: "pequeno",
      description: "300 ml",
      image:"http://myimage.jpg"
    }
  ) {
    createdAt
    name
    priceInDiamonds
    userId
  }
}

mutation DeleteProduct

headers

Content-Type: application/json
X-CSRF-Token: 6qxhPNFVm4n08BfIqemoAhN4_rA7FS-ED5PgAbQiqGvODkKP7CKL1z66XrJ3k-dJBgGNzABdU-hFBaD4bgmjZA
Bearer Token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1LCJleHAiOjE2NzYwNzk2OTJ9.3fKl0k5vdx839m7qqNK81QB2Q_vV2puup9y3UxbfUW0

body

mutation DeleteProduct {
  deleteProduct(input:{
    id: 11,
  }){
    name
  }
}

mutation UpdateProduct

headers

Content-Type: application/json
X-CSRF-Token: 6qxhPNFVm4n08BfIqemoAhN4_rA7FS-ED5PgAbQiqGvODkKP7CKL1z66XrJ3k-dJBgGNzABdU-hFBaD4bgmjZA
Bearer Token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1LCJleHAiOjE2NzYwNzk2OTJ9.3fKl0k5vdx839m7qqNK81QB2Q_vV2puup9y3UxbfUW0

body

mutation {
  updateProduct(input:{
    name: "Café com leite",
    id:13,
  }) {
    name,
    id
  }
}

QUERIES

query allProducts

headers

Content-Type: application/json
X-CSRF-Token: 6qxhPNFVm4n08BfIqemoAhN4_rA7FS-ED5PgAbQiqGvODkKP7CKL1z66XrJ3k-dJBgGNzABdU-hFBaD4bgmjZA
Bearer Token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1LCJleHAiOjE2NzYwNzk2OTJ9.3fKl0k5vdx839m7qqNK81QB2Q_vV2puup9y3UxbfUW0

body

{
  allProducts{
    id,
    name,
    userId,
    priceInDiamonds,
    shortDescription,
    description,
    createdAt
  }
}

query allCustomers

headers

Content-Type: application/json
X-CSRF-Token: 6qxhPNFVm4n08BfIqemoAhN4_rA7FS-ED5PgAbQiqGvODkKP7CKL1z66XrJ3k-dJBgGNzABdU-hFBaD4bgmjZA
Bearer Token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1LCJleHAiOjE2NzYwNzk2OTJ9.3fKl0k5vdx839m7qqNK81QB2Q_vV2puup9y3UxbfUW0

body

{
  allCustomers {
    email,
    cpf,
    id,
    uid
  }
}

query allTransactions

headers

Content-Type: application/json
X-CSRF-Token: 6qxhPNFVm4n08BfIqemoAhN4_rA7FS-ED5PgAbQiqGvODkKP7CKL1z66XrJ3k-dJBgGNzABdU-hFBaD4bgmjZA
Bearer Token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo1LCJleHAiOjE2NzYwNzk2OTJ9.3fKl0k5vdx839m7qqNK81QB2Q_vV2puup9y3UxbfUW0

body

{
  allTransactions {
    id,
    priceInCents,
    priceInDiamonds,
    transactionType,
    userId
  }
}