# GraphQL quickstart

You can access your flags without an SDK by sending a GraphQL query to [Hypertune Edge](https://docs.hypertune.com/concepts/hypertune-edge).

## 1. Write a GraphQL query

Go to the Preview view in the Hypertune UI and enter the following [GraphQL](https://graphql.org/learn/queries/) query:

```graphql
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:

```graphql
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.

{% tabs %}
{% tab title="cURL Example" %}

<pre class="language-bash" data-overflow="wrap"><code class="lang-bash"><strong>curl --location --request GET 'https://edge.hypertune.com/graphql?token=${YOUR_URL_ENCODED_PROJECT_TOKEN}&#x26;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'
</strong></code></pre>

{% endtab %}

{% tab title="JavaScript Example" %}

```javascript
/*
 * @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=${YOUR_URL_ENCODED_PROJECT_TOKEN}&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;
  });
}
```

{% endtab %}
{% endtabs %}
