How to use graphqurl - 10 common examples

To help you get started, we’ve selected a few graphqurl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hasura / json2graphql / test / verify.js View on Github external
const verifyDataImport = () => {
  let resp = null;
  return query({
    query: complexQuery,
    endpoint: `${process.env.TEST_HGE_URL}/v1/graphql`,
    headers: {'x-hasura-admin-secret': process.env.TEST_X_HASURA_ADMIN_SECRET},
  }).then(response => {
    resp = response;
    if (response.data.j2g_test_favoriteRoutes[0]
    .j2g_test_routesByJ2g_test_routesId
    .j2g_test_leaguesByJ2g_test_leaguesId
    .j2g_test_flightssByJ2g_test_leaguesId[0]
    .j2g_test_flightCommentssByJ2g_test_flightsId[0]
    .j2g_test_usersByJ2g_test_usersId.email === 'osxcode@gmail.com') {
      console.log('✔︎ Test passed');
    } else {
      console.log('✖ Test failed. Unexpected response.');
      console.log(response.data);
    }
github hasura / firebase2graphql / test / verifyChinook.js View on Github external
const verifyDataImport = () => {
  query({
    query: complexQuery,
    endpoint: `${process.env.TEST_HGE_URL}/v1/graphql`,
    headers: {'x-hasura-admin-secret': process.env.TEST_X_HASURA_ADMIN_SECRET},
  }).then(response => {
    if (
      response.data.f2g_test_Album[0].f2g_test_Album_artist.ArtistId === 1 &&
      response.data.f2g_test_Album[0].f2g_test_Track[0].Name === 'Breaking The Rules'
    ) {
      let sqlString = '';
      ['Album', 'Album_artist', 'Track'].forEach(t => {
        sqlString += `drop table public."f2g_test_${t}" cascade;`;
      });
      fetch(
        `${process.env.TEST_HGE_URL}/v1/query`,
        {
          method: 'POST',
github hasura / firebase2graphql / test / verifyChinookNested.js View on Github external
const verifyDataImport = () => {
  query({
    query: complexQuery,
    endpoint: `${process.env.TEST_HGE_URL}/v1/graphql`,
    headers: {'x-hasura-admin-secret': process.env.TEST_X_HASURA_ADMIN_SECRET},
  }).then(response => {
    if (
      response.data.f2gt_Album[0]._id === '1' &&
      response.data.f2gt_Album[0].f2gt_Track[1]._id === '10' &&
      response.data.f2gt_Album[0].f2gt_Artist.Name === 'AC/DC' &&
      response.data.f2gt_Album[0].f2gt_Artist.f2gt_Album[0].Title === 'Let There Be Rock' &&
      response.data.f2gt_Album[0].f2gt_Artist.f2gt_Album[0].f2gt_Track[0].Name === 'Bad Boy Boogie'
    ) {
      let sqlString = '';
      ['Album', 'Artist', 'Tracks'].forEach(t => {
        sqlString += `drop table public."f2gt_${t}" cascade;`;
      });
      fetch(
github hasura / firebase2graphql / test / verifyBlog.js View on Github external
const verifyDataImport = () => {
  query({
    query: complexQuery,
    endpoint: `${process.env.TEST_HGE_URL}/v1/graphql`,
    headers: {'x-hasura-admin-secret': process.env.TEST_X_HASURA_ADMIN_SECRET},
  }).then(response => {
    if (
      response.data.f2g_test_posts[0].title === 'My first post' &&
      response.data.f2g_test_users[0].username === 'Eena' &&
      response.data.f2g_test_user_posts[1].title === 'Whatta proaaa'
    ) {
      let sqlString = '';
      ['f2g_test_users', 'f2g_test_posts', 'f2g_test_user_posts'].forEach(t => {
        sqlString += `drop table public."${t}" cascade;`;
      });
      fetch(
        `${process.env.TEST_HGE_URL}/v1/query`,
        {
github hasura / cloud-functions-boilerplates / zeit-serverless / nodejs / mutation-trigger / index.js View on Github external
module.exports = async (req, res) => {
    let js;
    try {
        js = await json(req);
    } catch (err) {
        send(res, 400, {'error': err.message});
    }
    query(
        {
            query: q,
            endpoint: hgeEndpoint,
            variables: {noteId: js.event.data.old.id, data: js.event.data.old.note},
            headers: {
                'x-hasura-access-key': accessKey,
                'Content-Type': 'application/json'
            }
        }
    ).then((response) => {
        console.log(response);
        send(res, 200, {'message': response});
    }).catch((error) => {
        send(res, 400, {'message': error});
    });
};
github Thorium-Sim / thorium / server / src / helpers / graphqlClient.js View on Github external
query(queryParams) {
    return query({
      ...queryParams,
      endpoint: this.endpoint,
      headers: {
        authorization: `Bearer ${App.spaceEdventuresToken}`,
        ...queryParams.headers
      }
    });
  }
}
github hasura / graphql-engine / community / boilerplates / event-triggers / google-cloud-functions / nodejs6 / mutation / index.js View on Github external
gmaps.json().then( gmapsResponse => {
                if (gmapsResponse.results && gmapsResponse.results.length === 0) {
                    res.json({error: true, data: gmapsResponse, message: `no results for address ${address}`});
                    return;
                }
                const { lat, lng } = gmapsResponse.results[0].geometry.location;
                query({
                    query: MUTATION_UPDATE_LAT_LONG,
                    endpoint: HASURA_GRAPHQL_ENGINE_URL,
                    variables: { id, lat, lng },
                }).then( hgeResponse => {
                    res.json({error: false, data: hgeResponse.data});
                });
            });
        });
github hasura / cloud-functions-boilerplates / azure-functions / nodejs / mutation-trigger / HTTPTrigger / index.js View on Github external
module.exports = function (context, req) {
    context.log('JavaScript HTTP trigger function processed a request.');
    try {
        context.log('Inside');
        const { event: {op, data}, table } = req.body;
        context.log(data);
        context.log(data.new.id);
        const qv = {noteId: data.old.id, data: data.old.note};
        const hgeResponse = query({
              query: MUTATION_NOTE_REVISION,
              endpoint: HGE_ENDPOINT + '/v1alpha1/graphql',
              variables: qv,
              headers: {
                'x-hasura-access-key': ACCESS_KEY
              }
        }).then((response) => {
            context.log(response);
            context.log('After query');
            context.res = {
                body: {
                    error: false,
                    data: response
                }
            };
            context.done();
github hasura / firebase2graphql / src / import / insert.js View on Github external
const insertHundredRows = i => {
      let mutationString = '';
      let objectString = '';
      const variables = {};
      const numOfelementsToInsert = Math.min(numOfRows - insertedRows, 100);
      mutationString += `insert_${tableName} ( objects: $objects ) { affected_rows } \n`;
      objectString += `$objects: [${tableName}_insert_input!]!,\n`;
      variables.objects = [...transformedData[tableName].slice(i, numOfelementsToInsert + i)];
      const mutation = `mutation ( ${objectString} ) { ${mutationString} }`;
      spinnerStart(`Inserting ${i} to ${i + numOfelementsToInsert} rows of ${numOfRows} in table ${tableName}`);
      return query(
        {
          query: mutation,
          endpoint: `${url}/v1/graphql`,
          variables,
          headers,
        }
      ).then(response => {
        if (response.data) {
          spinnerStop('Done!');
          insertedRows += numOfelementsToInsert;
          if (insertedRows >= numOfRows) {
            return insertToTable(j + 1);
          }
          return insertHundredRows(i + 100);
        }
        deleteDataTill(tableName, insertOrder, url, headers).then(() => {
github hasura / graphql-engine / community / boilerplates / event-triggers / azure-functions / nodejs / mutation / HTTPTrigger / index.js View on Github external
module.exports = function (context, req) {
    context.log('JavaScript HTTP trigger function processed a request.');
    try {
        context.log('Inside');
        const { event: {op, data}, table } = req.body;
        context.log(data);
        context.log(data.new.id);
        const qv = {noteId: data.old.id, data: data.old.note};
        const hgeResponse = query({
              query: MUTATION_NOTE_REVISION,
              endpoint: HGE_ENDPOINT + '/v1/graphql',
              variables: qv,
              headers: {
                'x-hasura-admin-secret': ADMIN_SECRET
              }
        }).then((response) => {
            context.log(response);
            context.log('After query');
            context.res = {
                body: {
                    error: false,
                    data: response
                }
            };
            context.done();

graphqurl

cURL for GraphQL - CLI and JS library for making GraphQL queries

Apache-2.0
Latest version published 25 days ago

Package Health Score

89 / 100
Full package analysis

Popular graphqurl functions