Hypertune
Search
K

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"
}
}
) {
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.
JavaScript Example
cURL Example
/* Query: query TestQuery {
root(
context: {
environment: "DEVELOPMENT",
user: {
id: "test_id"
name: "Test"
}
}
) {
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;
});
}
curl --location --request GET 'https://edge.hypertune.com/graphql?token=YOUR_URL_ENCODED_TOKEN&body=%7B%22query%22%3A%22query%20TestQuery%20%7B%20root%28%20context%3A%20%7B%20environment%3A%20%5C%22DEVELOPMENT%5C%22%2C%20user%3A%20%7B%20id%3A%20%5C%22test_id%5C%22%20name%3A%20%5C%22Test%5C%22%20email%3A%20%5C%22test%40test.com%5C%22%20%7D%20%7D%20%29%20%7B%20exampleFlag%20%7D%20%7D%22%2C%22variables%22%3A%7B%7D%7D'