1.0.19 • Published 4 years ago

@grafee/client v1.0.19

Weekly downloads
37
License
MIT
Repository
-
Last release
4 years ago

Grafee Client

Grafee is the easiest way to create an awesome GraphQL API.

Getting started

yarn add @grafee/client

Technologies

API

gql

This is a template literal tag you can use to concisely write a GraphQL query that is parsed into the standard GraphQL AST

For more information: graphql-tag

import { gql } from "@grafee/client";

export const USERS = gql`
  query {
    users(offset: 0, limit: 10) {
      docs {
        id
        username
        email
      }
    }
  }
`;

createQuery

FULL API

import { createQuery } from '@grafee/client'
import { USER } from './queries'

const getUser = createQuery(USER)

const { data, loading, error, fetchMore } = getUser(opts?) // React Hooks

createMutation

FULL API

import { createMutation } from '@grafee/client'
import { CREATE_USER } from './mutations'

const userMutation = createMutation(CREATE_USER)

const [createUser, { data, loading, error }] = userMutation(opts?) // React Hooks

createLazyQuery

FULL API

import { createLazyQuery } from '@grafee/client'
import { USER } from './queries'

const getLazyUser = createLazyQuery(USER)

const [loadUser, { data, loading, error, colled }] = getLazyUser(opts?) // React Hooks

createSubscription

FULL API

import { createSubscription } from '@grafee/client'
import { SUB_USER } from './subscriptions'

const subUser = createSubscription(SUB_USER)

const { data, loading, error } = subUser(opts?) // React Hooks

getClient

client is now set to the ApolloClient instance being used by the application (that was configured using something like ApolloProvider

import { getClient } from "@grafee/client";

const client = getClient(); // React Hooks

FULL API

storage (localStorage)

To manage localStorage in easiest way

import { storage } from "@grafee/client";

storage.set(key, value); // localStorage.setItem
storage.get(key); // localStorage.getItem
storage.clear(); // localStorage.clear
storage.length(); // localStorage.length
storage.key(index); // localStorage.key(index)
storage.remove(key); // localStorage.removeItem(key)

MIT License

MIT License

Copyright (c) 2019 Yakauleu Uladzislau

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.