GraphQL quickstart
You can access your flags without an SDK by sending a GraphQL query to Hypertune Edge.
1. Write a GraphQL query
Go to the Preview view in the Hypertune UI and enter the following GraphQL query:
query TestQuery {
root {
exampleFlag
}
}
In the Result panel, you can see the flag that matches your query, including all of its logic.
Now pass the context
argument, containing the environment
and user
, 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 cURL and JavaScript snippets for the GraphQL query you entered.
curl --location --request GET 'https://edge.hypertune.com/graphql?token=U2FsdGVkX18OjQXXlXZi5aLfKm2K4bxBhHRQQo0EuWw%3D&body=%7B%22query%22%3A%22query%20TestQuery%7Broot(context%3A%7Benvironment%3A%20%5C%22development%5C%22%2C%20user%3A%7Bid%3A%20%5C%22test_id%5C%22%20name%3A%20%5C%22Test%5C%22%20email%3A%20%5C%22test%40test.com%5C%22%7D%7D)%7BexampleFlag%7D%7D%22%2C%22variables%22%3A%7B%7D%7D'
/*
* @param {Object} variables - e.g. {}
* @returns {Promise<Object>}
*/
function queryHypertune(variables) {
const query = `query TestQuery{root(context:{environment: "development", user:{id: "test_id" name: "Test" email: "test@test.com"}}){exampleFlag}}`;
return fetch(`https://edge.hypertune.com/graphql?token=U2FsdGVkX18OjQXXlXZi5aLfKm2K4bxBhHRQQo0EuWw%3D&body=${
encodeURIComponent(JSON.stringify({ query, 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