How to use the graphql-request.GraphQLClient function in graphql-request

To help you get started, we’ve selected a few graphql-request 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 startups-services / epic-admin-dashboard / pages / api / exec.js View on Github external
export default async function exec(req, res) {
  try {
    const graphQLClient = new GraphQLClient(process.env.graphcms_endpoint, {
      headers: {
        authorization: `Bearer ${process.env.graphcms_pat}`,
      },
      method: 'POST',
    });
    const result = await graphQLClient.request(req.body.query, req.body.variables);
    return res.status(200).send(result);
  } catch (e) {
    // eslint-disable-next-line no-console
    console.error(e);
    return res.status(502).send('bad request');
  }
}
github patcito / nextjob / pages / index.js View on Github external
// select distinct(locality), country, location from "Job"
    // select
    //       ST_Distance_Sphere(location::Geometry, ST_MakePoint(48.857091,
    //                   2.353702)) as distance
    //                    from
    //                        "Job"
    //                        create or replace function search_job_distance(lat float,long float)
    //                          returns table (distance float)
    //                          as
    //                          $body$
    //                          select ST_Distance_Sphere(location::Geometry, ST_MakePoint(lat,
    //                                     long)) as distance from  "Job"
    //
    //                                     $body$
    //                                     language sql;
    const client = new grequest.GraphQLClient(getJobsopts.uri, {
      headers: getJobsopts.headers,
    });
    let jobsAndCompanies = await client
      .request(getJobsopts.query, {
        ownerId: userId,
        userId: userInfo.userId,
        meId: meId,
        companyId: companyId,
        skill: skill,
        description: description,
        description_fr: description,
        remote: remote,
        employementType: employementType,
        country: country,
        locality: locality,
        nocompany: query.companies ? null : '_no_company_',
github Human-Connection / Human-Connection / backend / src / schema / resolvers / user_management.spec.js View on Github external
beforeEach(async () => {
    const adminParams = {
      role: 'admin',
      email: 'admin@example.org',
      password: '1234',
    }
    // create an admin user who has enough permissions to create other users
    await factory.create('User', adminParams)
    const headers = await login(adminParams)
    authenticatedClient = new GraphQLClient(host, { headers })
    // but also create an unauthenticated client to issue the `User` query
    client = new GraphQLClient(host)
  })
github TimothyCole / timcole.me / frontend / graphql-client.js View on Github external
import { GraphQLClient } from 'graphql-request';
const _TWITCH_CLIENT_ID = "kimne78kx3ncx6brgo4mv6wki5h1ko";

const client = new GraphQLClient('https://gql.twitch.tv/gql', {
	headers: {
		"Client-ID": _TWITCH_CLIENT_ID
	},
})

module.exports = function () {
	return {
		graphql(query) { return client.request(query); }
	}
}
github patcito / nextjob / pages / applications.js View on Github external
if (rm) {
      const acceptApplicationopts = {
        uri: getHasuraHost(process, undefined, publicRuntimeConfig),
        json: true,
        query: updateJobApplicationStatus.loc.source.body,
        headers: {
          'x-access-token': Cookies.get('token'),
          'x-access-role': 'userType',
        },
      };
      let vars = {
        id: jobApplication.id,
        status: true,
      };

      const client = new grequest.GraphQLClient(acceptApplicationopts.uri, {
        headers: acceptApplicationopts.headers,
      });

      client.request(acceptApplicationopts.query, vars).then(gdata => {
        this.handleUpdateCallback(
          this.i18n.t(
            'applications:This application has been accepted successfully',
          ),
        );
      });
    }
  };
github unite-cms / unite-cms / src / Bundle / CoreBundle / Resources / webpack / vue / views / Sortable.vue View on Github external
created: function () {
        this.client = new GraphQLClient(this.endpoint, {
            credentials: "same-origin",
            headers: {
                "Authentication-Fallback": true,
                "X-CSRF-TOKEN": this.csrf_token
            },
        });

        this.loadData();
    },
    mounted: function(){
github coderplanets / coderplanets_web / utils / graphql_helper.js View on Github external
export const makeGithubExplore = (GRAPHQL_ENDPOINT, token) => {
  const client = new GraphQLClient(GRAPHQL_ENDPOINT, {
    headers: {
      authorization: `bearer ${token}`,
    },
  })
  return client
}
github CreativeBuilds / creative-bot / src / renderer / helpers / dlive / sendMessage.ts View on Github external
return new Promise((res, rej) => {
    const client = new GraphQLClient('https://api.dlive.tv/', {
      headers: {
        authorization: authToken
      }
    });

    const query = `
        mutation sendStreamchatMessage($input: SendStreamchatMessageInput!) {
          sendStreamchatMessage(input: $input) {
            err {
              code
              message
              __typename
            }
            __typename
          }
        }
github Human-Connection / Human-Connection / backend / src / middleware / notifications / spec.js View on Github external
beforeEach(async () => {
          const createPostMutation = `
          mutation($title: String!, $content: String!) {
            CreatePost(title: $title, content: $content) {
              id
              title
              content
            }
          }
          `
          authorClient = new GraphQLClient(host, { headers: authorHeaders })
          const { CreatePost } = await authorClient.request(createPostMutation, { title, content })
          post = CreatePost
        })
github brightleaf / react-hooks / src / use-mutation.js View on Github external
const useMutation = function(url, query, options = {}) {
  const client = new GraphQLClient(url, options)

  const [state, dispatch] = useReducer(reducer, {
    data: [],
    error: null,
    loading: false,
  })
  const makeQuery = async variables => {
    dispatch({ type: 'get' })
    const resp = await client.request(query, variables)
    const data = resp
    dispatch({ type: 'success', payload: { data } })
  }

  return { ...state, makeQuery }
}

graphql-request

Minimal GraphQL client supporting Node and browsers for scripts or simple apps

MIT
Latest version published 11 months ago

Package Health Score

88 / 100
Full package analysis