New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

just-graphql

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

just-graphql

A small extenstion created to handle graphql requests.

latest
Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
7
Maintainers
1
Weekly downloads
 
Created
Source

just-graphql

A small extenstion created to handle graphql requests.

Usage


  justGraphql(
    address,
    query/mutations payload,
    variables/mutations data,
    token,
    onSuccess callback,
    onFailure callback,
    HTTP request returning new token in case of error/expiration
  )

Queries

import justGraphql from 'just-graphql';
var JWT = require('jwt-client');
var jQuery = require("jquery");

justGraphql(`server_address/graphql`,
  `query Notifications {
    me {
      notifications(first: 10, order: "created_at DESC") {
        pageInfo {
          startCursor,
          endCursor,
          hasNextPage,
          hasPreviousPage
        },
        totalCount,
        edges {
          cursor,
          node {
            id,
            type,
            data,
            read_at,
            created_at
          }
        }
      }
    }
  }`, {
    variables: {
      //no variables
    }
  },
  `Bearer ${JWT.get()}`,
  function(response) {
    console.log(response);
  },
  function(err) {
    alert(err);
  },
  function() {
    return (
      jQuery.ajax({
        url: `server_address/refresh/token`,
        type: 'GET',
        headers: {
          Authorization: 'Bearer ' + JWT.get()
        }
      })
      .then(function (response) {
        JWT.forget();
        JWT.keep(response.token);

        return response.token;
      });
    )
  }
)
.then((data) => {
  // pass data back to components state or Redux's store
});

Mutations

import justGraphql from 'just-graphql';
var JWT = require('jwt-client');
var jQuery = require("jquery");

justGraphql(`server_address/graphql`,
  `mutation DeleteRecords($input: DeleteRecordInput!) {
    deleteRecord(input: $input) {
      user {
        records
      }
    }
  }`, {
    variables: {
      data
    }
  },
  'Bearer ' + JWT.get(),
  function(response) {
    console.log(response);
  },
  function(err) {
    alert(err)
  }
  function() {
    return (
      jQuery.ajax({
        url: `server_address/refresh/token`,
        type: 'GET',
        headers: {
          Authorization: 'Bearer ' + JWT.get()
        }
      })
      .then(function (response) {
        JWT.forget();
        JWT.keep(response.token);

        return response.token;
      });
    )
  }
).then((data) => {
  // pass data back to components state or Redux's store
});

FAQs

Package last updated on 18 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts