GraphQL quickstart

You can access your flags without an SDK by sending a GraphQL query to our low latency edge server.

1. Write a GraphQL query

Navigate to the Preview tab in the Hypertune UI and enter the following GraphQL query:

query TestQuery {
  root {
    exampleFlag
  }
}

In the Result tab, you can see the flag that matches your query, including all of its logic.

Now pass the context argument containing the user object in the query:

query TestQuery {
  root(
    context: {
      environment: "DEVELOPMENT",
      user: {
        id: "test_id"
        name: "Test"
        email: "test@test.com"
      }
    }
  ) {
    exampleFlag
  }
}

Now your flag logic has been reduced, i.e. the "If / Else" expression has been replaced with its result.

2. Get code snippets

Switch to the Code Snippets tab to see JavaScript and cURL snippets for the GraphQL query you entered.

/* Query: query TestQuery {
  root(
    context: {
      environment: "DEVELOPMENT",
      user: {
        id: "test_id"
        name: "Test"
        email: "test@test.com"
      }
    }
  ) {
    exampleFlag
  }
}
Example Variables: {} */
function fetchConfigFromHypertune(variables) {
  return fetch(`https://edge.hypertune.com/graphql?token=YOUR_URL_ENCODED_TOKEN&body=${
      encodeURIComponent(JSON.stringify({
        query: "query TestQuery { root( context: { environment: \"DEVELOPMENT\", user: { id: \"test_id\" name: \"Test\" email: \"test@test.com\" } } ) { exampleFlag } }",
        variables: variables
      }))
    }`, {
    method: "GET",
    redirect: "follow",
    referrerPolicy: "no-referrer-when-downgrade",
    keepalive: true
  })
  .then((response) => {
    return response.json();
  })
  .then((result) => {
    if (result.data) {
      return result.data;
    }
    throw result;
  });
}

Last updated