Socket
Book a DemoInstallSign in
Socket

@hexworks/cobalt-graphql

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hexworks/cobalt-graphql

GraphQL Client for Cobalt.

Source
npmnpm
Version
2022.1.1-PREVIEW
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

GraphQL Client for Cobalt

This library wraps the Apollo GraphQL Client with Functional Programming constructs, and also adds data validation and error handling.

Usage:

📘 Note that this library uses io-ts for data valiation.

First, you have to create an io-ts codec that represents the data that you'll receive:

import * as t from "io-ts";

const Events = t.array(
    t.strict({
        id: t.number,
        name: t.string,
    })
);

a GraphQL query:

import { DocumentNode } from "graphql";
import gql from "graphql-tag";

const query: DocumentNode = gql`
    query events($limit: Int) {
        events(first: $limitF) {
            id
            name
        }
    }
`;

and the corresponding client:

import { createGraphQLClient } from "@hexworks/cobalt-graphql";

const client = createGraphQLClient(URL);

Then you can call query to get your result:

const result = client.query(query, { limit: 10}, this.codec))

Keywords

hexworks

FAQs

Package last updated on 05 Jun 2022

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