use GraphQL query on Production

Follow the GraphQL documentation, You have 2 ways to use graphql.

service URL endpoint

The endpoint of GraphQL is the same as the GraphQLi URL.

For example https://demo.privagepos.com/graphql

use GraphQL client library

GraphQL has many support for popular programming languages. (See here https://graphql.org/code). We recommend to use the client to get the data from ours service. It reduce your time to manage the request to the GraphQL service.

use basic HTTP request

You can use pure HTTP request for get the data

info

We only accept POST method for query any data.

curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: MY-SECRET-API-KEY" \
  --data '{ "query": "{ todos { edges { node { id completed text } } } }" }' \
  https://demo.privagepos.com/graphql

for example, we use fetch to get the data.

fetch('https://demo.privagepos.com/graphql', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-KEY': 'MY-SECRET-API-KEY'
  },
  body: JSON.stringify({ query: `
    query {
      todos {
        edges {
          node {
            completed
            id
            text
          }
          }
      }
    }`
  }),
})
.then(res => res.json())
.then(res => console.log(res.data));
Last updated on