0.14.16 • Published 8 months ago

@data-client/graphql v0.14.16

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

Data Client for GraphQL

CircleCI Coverage Status npm downloads bundle size npm version PRs Welcome Chat

GraphQL Endpoints for Data Client

📖Read The Docs  |  🎮Github Demo

Define GraphQL endpoint

const gql = new GQLEndpoint('https://nosy-baritone.glitch.me');

Simple TypeScript definition

class User extends GQLEntity {
  name = '';
  email = '';
}

Write type-safe queries

const userList = gql.query(
  `{
    users {
      id
      name
      email
      }
    }`,
  { users: [User] },
);

const userDetail = gql.query(
  `query UserDetail($name: String!) {
    user(name: $name) {
      id
      name
      email
    }
  }`,
  { user: User },
);

One line data-hookup

const { user } = useSuspense(userDetail, { name: 'Fong' });
return (
  <>
    <h2>{user.name}</h2>
    <p>{user.email}</p>
  </>
);

Mutations

const gql = new GQLEndpoint('https://graphql.org/swapi-graphql');

const createReview = gql.mutation(
  `mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) {
    createReview(episode: $ep, review: $review) {
      stars
      commentary
    }
  }`,
  { createReview: Review },
);
const controller = useController();
const createReview = useFetcher(createReview);
return <ReviewForm onSubmit={data => controller.fetch(createReview, data)} />;

API

Networking definition

0.14.16

8 months ago

0.14.12

9 months ago

0.14.11

10 months ago

0.14.10

10 months ago

0.14.6

11 months ago

0.14.8

11 months ago

0.14.0

11 months ago

0.14.1

11 months ago

0.14.3

11 months ago

0.13.4

12 months ago

0.14.4

11 months ago

0.12.7

1 year ago

0.12.6

1 year ago

0.12.3

1 year ago

0.11.3

1 year ago

0.11.1

1 year ago

0.11.0

1 year ago

0.10.0

1 year ago

0.9.9

2 years ago

0.9.4

2 years ago

0.9.3

2 years ago

0.9.2

2 years ago

0.9.0

2 years ago

0.8.2

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago