Skip to main content

Query GraphQL APIs


This page is work-in-progress as we add additional languages.

GraphQL is a query language for APIs. DataSQRL exposes GraphQL APIs that can be queried from any programming language or application. This page provides examples for querying GraphQL APIs in various languages to help you get started. It is neither complete nor comprehensive. For a complete resource on GraphQL visit This page is only meant to get you started.

If you are unfamiliar with GraphQL, we recommend that you learn about GraphQL before proceeding.

For the example code snippets below, we are following the DataSQRL tutorial and assume you are running the Quickstart SQRL script on your local machine. To connect to a different server or use a different example, you need to change the server URI and query examples.

GraphQL Playground

DataSQRL includes GraphiQL which allows you to create, execute, and profile queries as well as inspect the GraphQL API directly in your browser.

After you run your SQRL script on your machine, open the URL http://localhost:8888//graphiql/ in a browser to access GraphiQL.

Now, you can paste GraphQL queries into the left-hand panel and hit the play button in the middle to see the result in the right-hand panel.

GraphiQL shows you the GraphQL schema of the API by opening the "Documentation" tab. You can inspect the schema to validate that DataSQRL generated your data API correctly.

GraphiQL also allows you to specify arguments for variables in your queries and set headers. It's a user-friendly IDE for designing GraphQL queries.


Apollo Client

Import and configure the Apollo GraphQL client as follows. If you don't have the client installed, run npm install @apollo/client graphql first.

import {ApolloClient, gql, InMemoryCache} from "@apollo/client";

const client = new ApolloClient({
uri: "http://localhost:8888//graphql",
cache: new InMemoryCache(),

Now, you can execute GraphQL queries as follows:

query CustomerSpending($customerid: Int!) {
Customers(id: $customerid) {
spending {

const customerid = 10;

variables: { customerid },
.then(result => console.log(result));

Apollo Client React

additional clients coming soon


Spring Boot