SiJago - GraphQL Client for Browser and Node.js

Overview

SiJago (GraphQL Client)

Build Status Coverage Status CodeFactor codebeat badge Codacy Badge node-current npm PRs Welcome

SiJago is GraphQL Client for Browser and Node.js, You can write request GraphQL schema using JavaScript Object Style, Why i create this tools, Because for reducing typo when writing GraphQL schema using HTTP client like Axios, Fetch or GraphQL client using Apollo and also to simplify calling the GraphQL schema easy to understand for human.

Table Of Content

Installation

npm install sijago -S or yarn add sijago -S

Feature

  • Mutation
  • Query
  • Inline Fragments
  • Variables (Comingsoon)
  • Fragments (Comingsoon)
  • Operation Name (Comingsoon)
  • Aliases (Comingsoon)
  • Directives (Comingsoon)
  • Subscription (Comingsoon)

SiJago Options

  • url: is used for the address the graphql server that will be used to interaction.
  • input: is used to send given request from client to graphql server, usually used when using mutation or query.
  • body: is used to display the response data provided by the graphql server.
  • headers: is used for interface of the Fetch API allows you to perform various actions on HTTP request and response headers.

SiJago Properties

  • Scalar

    Scalar is used for data type identification in your GraphQL Schema, something like scalar.GraphqlString is equals to String in GraphQL Schema, Important this scalar is fake because, it is only used for data type identification in GraphQL Schema, and this below is scalar type identification support which you can use.

    • GraphqlString
    • GraphqlNumber
    • GraphqlFloat
    • GraphqlBoolean
    • GraphqlDate
    • GraphqlObject
    • GraphqlArray
    • GraphqlArrayObject
    • GraphqlBuffer
  • Configs

    Configs is used for global custome headers, for interation request between client and server.

    • url: is used for the address of the graphql server that will be used to interaction.
    • origin: is used for response header indicates whether the response can be shared with requesting code from the given origin.
    • method: used for response header specifies one or more methods allowed when accessing a resource in response or request.
    • allowedHeaders: ise used for response header is used in response to a preflight request can be used during the actual request.
    • exposedHeaders: is used for response header allows a server to indicate which response headers should be made available.
    • credentials: is used for response header tells http whether to expose the response to server.
    • maxAge: is used for response header indicates how long the results of a preflight request can be cached.
    • auth: is used for request header can be used to provide credentials that authenticate a user agent with a server.
    • responseType: is used representation header is used to indicate the original media type of the resource.
    • cache: is used HTTP header field holds directives in both requests and responses, that control caching.
    • compression: is used for compress the message data without losing information about the origin media type.
    • headers: is used for interface of the Fetch API allows you to perform various actions on HTTP request and response headers.

SiJago Methods

  • Query(options: SiJagoOptions): Promise(SiJagoResponse) | Promise(Object)

    Query allow your get data from server-side, and it also returns an object based on the operation performed.

  • Mutation(options: SiJagoOptions): Promise(SiJagoResponse) | Promise(Object)

    Mutation allow you to modify server side data, and it also returns an object based on the operation performed. It can be used to insert, update, or delete data.

Example Usage

  • Before Usage Using SiJago With CommonJS Module
    const fetch = require('node-fetch')
    
    (async function() {
      fetch('https://graphqlzero.almansi.me/api', {
        method: 'POST',
        body: JSON.strgify({
          query:`
              albums(options: { sort: { order: DESC } }) {
              data {
                id
                title
                user {
                  name
                  email
                }
                photos {
                  data {
                    title
                    url
                  }
                }
              }
            }
          `
        })
       })
    })()
  • After Usage Using SiJago With CommonJS Module
    const { sijago } = require('sijago')
    
    (async function() {
      const { res } = await sijago.query({
        url: 'https://graphqlzero.almansi.me/api',
        input: { options: { sort: { order: 'DESC' } } },
        body: {
          albums: {
            data: {
              title: sijago.scalar.GraphqlString,
              user: {
                name: sijago.scalar.GraphqlString,
                email: sijago.scalar.GraphqlString
              },
              photos: {
                data: {
                  title: sijago.scalar.GraphqlString,
                  url: sijago.scalar.GraphqlString
                }
              }
            }
          }
        }
      })
    })()
    
    /** Example response usage if you use sijago graphql client
    {
      data: { albums: { data: [Array] } },
      error: undefined,
      url: 'https://graphqlzero.almansi.me/api',
      status: 200,
      statusText: 'OK',
      headers: Headers {
        [Symbol(map)]: [Object: null prototype] {
          'content-type': [Array],
          'transfer-encoding': [Array],
          connection: [Array],
          'access-control-allow-credentials': [Array],
          date: [Array],
          'access-control-allow-origin': [Array],
          'x-vercel-cache': [Array],
          server: [Array],
          'x-vercel-id': [Array],
          'strict-transport-security': [Array],
          'cache-control': [Array],
          'content-encoding': [Array]
        }
      }
    }
    */
  • Before Usage Using SiJago With ESM Module
    import fetch from 'node-fetch'
    
    (async function() {
      fetch('https://graphqlzero.almansi.me/api', {
        method: 'POST',
        body: JSON.strgify({
          query:`
              albums(options: { sort: { order: DESC } }) {
              data {
                id
                title
                user {
                  name
                  email
                }
                photos {
                  data {
                    title
                    url
                  }
                }
              }
            }
          `
        })
       })
    })()
  • After Usage Using SiJago With ESM Module
    import { sijago } from 'sijago'
    
    (async function() {
      const { res } = await sijago.query({
        url: 'https://graphqlzero.almansi.me/api',
        input: { options: { sort: { order: 'DESC' } } },
        body: {
          albums: {
            data: {
              title: sijago.scalar.GraphqlString,
              user: {
                name: sijago.scalar.GraphqlString,
                email: sijago.scalar.GraphqlString
              },
              photos: {
                data: {
                  title: sijago.scalar.GraphqlString,
                  url: sijago.scalar.GraphqlString
                }
              }
            }
          }
        }
      })
    })()
    
    /** Example response usage if you use sijago graphql client
    {
      data: { albums: { data: [Array] } },
      error: undefined,
      url: 'https://graphqlzero.almansi.me/api',
      status: 200,
      statusText: 'OK',
      headers: Headers {
        [Symbol(map)]: [Object: null prototype] {
          'content-type': [Array],
          'transfer-encoding': [Array],
          connection: [Array],
          'access-control-allow-credentials': [Array],
          date: [Array],
          'access-control-allow-origin': [Array],
          'x-vercel-cache': [Array],
          server: [Array],
          'x-vercel-id': [Array],
          'strict-transport-security': [Array],
          'cache-control': [Array],
          'content-encoding': [Array]
        }
      }
    }
    */
  • Example Usage Using SiJago With Local Headers
    import { sijago } from 'sijago'
    
    (async function() {
      const { res } = await sijago.query({
        url: 'https://graphqlzero.almansi.me/api',
        input: { options: { sort: { order: 'DESC' } } },
        body: {
          albums: {
            data: {
              title: sijago.scalar.GraphqlString,
              user: {
                name: sijago.scalar.GraphqlString,
                email: sijago.scalar.GraphqlString
              },
              photos: {
                data: {
                  title: sijago.scalar.GraphqlString,
                  url: sijago.scalar.GraphqlString
                }
              }
            }
          },
          headers: {
             origin: 'graphqlzero.almansi.me',
             methods: ['POST', 'GET', 'PUT', 'DELETE', 'HEAD', 'OPTIONS']
          }
        }
      })
    })()
    
    /** Example response usage if you use sijago graphql client
      {
        data: { albums: { data: [Array] } },
        error: undefined,
        url: 'https://graphqlzero.almansi.me/api',
        status: 200,
        statusText: 'OK',
        headers: Headers {
          [Symbol(map)]: [Object: null prototype] {
            'content-type': [Array],
            'transfer-encoding': [Array],
            connection: [Array],
            'access-control-allow-credentials': [Array],
            date: [Array],
            'access-control-allow-origin': [Array],
            'x-vercel-cache': [Array],
            server: [Array],
            'x-vercel-id': [Array],
            'strict-transport-security': [Array],
            'cache-control': [Array],
            'content-encoding': [Array]
          }
        }
      }
    */
  • Example Usage Using SiJago With Global Headers
    import { sijago } from 'sijago'
    
    sijago.configs = {
      url: 'https://graphqlzero.almansi.me/api',
      origin: 'graphqlzero.almansi.me',
      methods: ['POST', 'GET', 'PUT', 'DELETE', 'HEAD', 'OPTIONS']
    }
    
    (async function() {
      const { res } = await sijago.query({
        input: { options: { sort: { order: 'DESC' } } },
        body: {
          albums: {
            data: {
              title: sijago.scalar.GraphqlString,
              user: {
                name: sijago.scalar.GraphqlString,
                email: sijago.scalar.GraphqlString
              },
              photos: {
                data: {
                  title: sijago.scalar.GraphqlString,
                  url: sijago.scalar.GraphqlString
                }
              }
            }
          }
        }
      })
    })()
    /** Example response usage if you use sijago graphql client
      {
        data: { albums: { data: [Array] } },
        error: undefined,
        url: 'https://graphqlzero.almansi.me/api',
        status: 200,
        statusText: 'OK',
        headers: Headers {
          [Symbol(map)]: [Object: null prototype] {
            'content-type': [Array],
            'transfer-encoding': [Array],
            connection: [Array],
            'access-control-allow-credentials': [Array],
            date: [Array],
            'access-control-allow-origin': [Array],
            'x-vercel-cache': [Array],
            server: [Array],
            'x-vercel-id': [Array],
            'strict-transport-security': [Array],
            'cache-control': [Array],
            'content-encoding': [Array]
          }
        }
      }
    */
  • Example Usage Using SiJago With Global Custome Headers
    import { sijago } from 'sijago'
    
    sijago.configs.headers.set('Content-Type', 'application/graphql')
    sijago.configs.headers.set('Accept', 'application/graphql')
    
    (async function() {
      const { res } = await sijago.query({
        input: { options: { sort: { order: 'DESC' } } },
        body: {
          albums: {
            data: {
              title: sijago.scalar.GraphqlString,
              user: {
                name: sijago.scalar.GraphqlString,
                email: sijago.scalar.GraphqlString
              },
              photos: {
                data: {
                  title: sijago.scalar.GraphqlString,
                  url: sijago.scalar.GraphqlString
                }
              }
            }
          }
        }
      })
    })()
    /** Example response usage if you use sijago graphql client
      {
        data: { albums: { data: [Array] } },
        error: undefined,
        url: 'https://graphqlzero.almansi.me/api',
        status: 200,
        statusText: 'OK',
        headers: Headers {
          [Symbol(map)]: [Object: null prototype] {
            'content-type': [Array],
            'transfer-encoding': [Array],
            connection: [Array],
            'access-control-allow-credentials': [Array],
            date: [Array],
            'access-control-allow-origin': [Array],
            'x-vercel-cache': [Array],
            server: [Array],
            'x-vercel-id': [Array],
            'strict-transport-security': [Array],
            'cache-control': [Array],
            'content-encoding': [Array]
          }
        }
      }
    */

Testing

  • Testing Via Local

    npm test or make test
  • Testing Via Local And Build

    make build
  • Testing Via Docker

    docker build -t sijago or make dkb tag=sijago

Bugs

For information on bugs related to package libraries, please visit here

Contributing

Want to make sijago more perfect ? Let's contribute and follow the contribution guide.

License

BACK TO TOP

You might also like...

📞 NODE.TS - WhatsApp proxy for Discord

📞 NODE.TS - WhatsApp proxy for Discord

📞 NODE.TS - WhatsApp proxy for Discord

Mar 2, 2022

The perfect library for adding search, sort, filters and flexibility to tables, lists and various HTML elements. Built to be invisible and work on existing HTML.

List.js Perfect library for adding search, sort, filters and flexibility to tables, lists and various HTML elements. Built to be invisible and work on

Jan 1, 2023

Drag and drop library for two-dimensional, resizable and responsive lists

GridList Drag and drop library for a two-dimensional resizable and responsive list of items Demo: http://hootsuite.github.io/grid/ The GridList librar

Dec 14, 2022

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings

JavaScript Algorithms and Data Structures This repository contains JavaScript based examples of many popular algorithms and data structures. Each algo

Dec 31, 2022

A lightweight jQuery plugin for collapsing and expanding long blocks of text with "Read more" and "Close" links.

Readmore.js V3 alpha I am deprecating the 2.x version of Readmore.js. A new version is coming soon! Check it out and help me test it! Readmore.js A sm

Nov 30, 2022

FriendAdvisor is a mobile app with a focus on allowing friends and family to coordinate and receive text notifications about upcoming group events.

FriendAdvisor is a mobile app with a focus on allowing friends and family to coordinate and receive text notifications about upcoming group events.

Sep 29, 2022

Defines the communication layer between mobile native(iOS/Android) and webview using JSON Schema and automatically generates SDK code

Defines the communication layer between mobile native(iOS/Android) and webview using JSON Schema and automatically generates SDK code.

Dec 8, 2022

A responsive image polyfill for picture, srcset, sizes, and more

Picturefill A responsive image polyfill. Authors: See Authors.txt License: MIT Picturefill has three versions: Version 1 mimics the Picture element pa

Dec 31, 2022

A high-performance, dependency-free library for animated filtering, sorting, insertion, removal and more

MixItUp 3 MixItUp is a high-performance, dependency-free library for animated DOM manipulation, giving you the power to filter, sort, add and remove D

Dec 24, 2022
Releases(v1.0.1)
Owner
Restu Wahyu Saputra
A bright future will come, just waiting times, someday I will definitely become a software engineer
Restu Wahyu Saputra
🌳 Tiny & elegant JavaScript HTTP client based on the browser Fetch API

Huge thanks to for sponsoring me! Ky is a tiny and elegant HTTP client based on the browser Fetch API Ky targets modern browsers and Deno. For older b

Sindre Sorhus 8.5k Jan 2, 2023
Serverless Lambda functions with Apollo GraphQL and Airtable

Serverless Lambda functions with Apollo GraphQL and Airtable First, clone the repo: git clone

Max Stoiber 3 Dec 23, 2021
wasteof-client is an npm package for wasteof.money

wasteof-client is an npm package for wasteof.money

Oren Lindsey 2 Jun 16, 2022
API routes are great for APIs, but for small projects where you have to access server data or hide application logic, you can just call a server function from the client.

API routes are great for APIs, but for small projects where you have to access server data or hide application logic, you can just call a server function from the client.

null 3 Mar 6, 2022
Browser fingerprinting library with the highest accuracy and stability.

FingerprintJS is a browser fingerprinting library that queries browser attributes and computes a hashed visitor identifier from them. Unlike cookies a

FingerprintJS 18.1k Dec 31, 2022
a browser detector

Bowser A small, fast and rich-API browser/platform/engine detector for both browser and node. Small. Use plain ES5-version which is ~4.8kB gzipped. Op

Denis Demchenko 5.2k Jan 2, 2023
A Featureful File Browser for Cockpit

Cockpit Navigator A Featureful File System Browser for Cockpit - remotely browse, manage, edit, upload, and download files on your server through your

45Drives 226 Dec 27, 2022
Extensive math expression evaluator library for JavaScript and Node.js

?? Homepage Fcaljs is an extensive math expression evaluator library for JavaScript and Node.js. Using fcal, you can perform basic arithmetic, percent

Santhosh Kumar 93 Dec 19, 2022
BotsApp is an optimized and easy-to-use WhatsApp UserBot written in Node.js

?? BotsApp ?? Your Personal Assisstant, on WhatsApp! BotsApp is an optimized and easy-to-use WhatsApp UserBot written in Node.js. Utilize your persona

BotsApp 5.5k Jan 1, 2023
A simple stateless microservice in Nodejs, Built with Node.js, Express and Mocha

A Stateless Microservice in NodeJS, having three major functionalities - Authentication, JSON patching and Image Thumbnail Generation.

Christotle Agholor 3 Feb 26, 2022