Nerdy People Matriculate
Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

jraph

2.0.1 • Public • Published

jraph

A simple fetch-wrapper for making GraphQL API calls in a jiff!

jraph is written in typescript, but can be used in both a VanillaJS and a TypeScript context.

|   Note that for the purposes of this project, we will use sample data from an ApolloGraphQL API I created on CodeSandbox, check it out by clicking the button below.

Edit GraphQL Example API

VanillaJS Examples

Queries

    import {jraph} from 'jraph';
 
    async function getItems(){
        const jql = jraph(
            "https://csb-xpwq1o2824-alczxhlphl.now.sh/",
            {
                method: "POST"
            }
        });
        return (
            jql`{
                items{
                    title
                    info
                }
            }`
        );
    }
 
    async function showStuff(){
        console.log(await getItems())
    }

Mutations

    import {jraph} from 'jraph';
 
    async function addItem(){
        const jql = jraph(
            "https://csb-xpwq1o2824-alczxhlphl.now.sh/",
            {
                method: "POST"
            }
        });
        return (
            jql`
            mutation{
                addItem(title: "egg", info: "salad"){
                    title
                    info
                }
            }`
        );
    }
 
    async function showStuff(){
        console.log(await addItem())
    }

typescript example coming soon

install

npm i jraph

Downloadsweekly downloads

2

version

2.0.1

license

MIT

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability