Tags

GraphQL
Data

On this page

Playground

Graphql

Connecting your client

Playground

The playground is located within caisy you can access it over the main navigation. You are already authorised with your current session token.


What you will also find on this screen is the URL of your Graphql endpoint, which contains your project ID - in this case:

https://cloud.caisy.io/api/v3/e/aa0943f2-af8e-4920-afe5-96e7c6fb7b01/graphql

If you want to connect from an external Graphql client, you need either a personal access token or an apikey (recommended). To create this, see here:

Once you have your APIKEY, you need to set up a Graphql client in your project. Here is an example of how to do this with graphql-request:

to install graphql-request run npm install graphql-request or yarn add graphql-request

after using the library you code might look like this:

import { GraphQLClient, gql } from 'graphql-request'

async function main() {
  const graphQLClient = new GraphQLClient(process.env.CAISY_GQL_ENDPOINT, {
    headers: {
      "x-caisy-apikey": process.env.CAISY_API_KEY,
    },
  })

  const query = gql`
		query MyQuery {
		  allPage {
		    edges {
		      node {
		        slug
		        id
		      }
		    }
		  }
		}
  `

  const data = await graphQLClient.request(query)
  console.log(JSON.stringify(data, undefined, 2))
}

main().catch((error) => console.error(error))  

where CAISY_API_KEY which you copied from caisy and looks like this 6MRfDFymt9otDutFEHSwVSJHv870lPPQ. The CAISY_GQL_ENDPOINT is your graphql endpoint and looks like this https://cloud.caisy.io/api/v3/e/aa0943f2-af8e-4920-afe5-96e7c6fb7b01/graphql

You should replace both variables with your own values


Tags

GraphQL
Data

On this page

Playground