Hypertune
  • Introduction
  • Getting Started
    • Set up Hypertune
    • Next.js (App Router) quickstart
    • Next.js (Pages Router) quickstart
    • React quickstart
    • Remix quickstart
    • Gatsby quickstart
    • Vue quickstart
    • Nuxt quickstart
    • Node.js quickstart
    • React Native quickstart
    • JavaScript quickstart
    • Python quickstart
    • Rust quickstart
    • Go quickstart
    • Web quickstart
    • GraphQL quickstart
  • Example apps
    • Next.js and Vercel example app
  • Concepts
    • Architecture
    • Project
    • Schema
    • Flag lifecycle
    • Logic
    • Variables
    • Splits
    • A/B tests
    • Staged rollouts
    • Multivariate tests
    • Machine learning loops
    • Events
    • Funnels
    • Hypertune Edge
    • Reduction
    • SDKs
    • GraphQL API
    • Git-style version control
    • App configuration
  • Use Cases
    • Feature flags and A/B testing
    • Landing page optimization
    • In-app content management
    • Pricing plan management
    • Permissions, rules and limits
    • Optimizing magic numbers
    • Backend configuration
    • Product analytics
  • Integrations
    • Vercel Edge Config integration
    • Google Analytics integration
    • Segment integration
    • Webhooks
      • Creating webhooks
      • Handling webhooks
  • SDK Reference
    • Installation
    • Type-safe client generation
    • Initialization
    • Build-time logic snapshot
    • Hard-coded fallbacks
    • Local-only, offline mode
    • Hydrate from your own server
    • Wait for server initialization
    • Provide targeting attributes
    • Local, synchronous evaluation
    • Remote logging
    • Getting flag updates
    • Serverless environments
    • Vercel Edge Config
    • Custom logging
    • Shutting down
Powered by GitBook
On this page
  • 1. Write a GraphQL query
  • 2. Get code snippets
  1. Getting Started

GraphQL quickstart

PreviousWeb quickstartNextNext.js and Vercel example app

Last updated 6 months ago

You can access your flags without an SDK by sending a GraphQL query to .

1. Write a GraphQL query

Go to the Preview view in the Hypertune UI and enter the following 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=${YOUR_URL_ENCODED_PROJECT_TOKEN}&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=${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;
  });
}
Hypertune Edge
GraphQL