Socket
Book a DemoInstallSign in
Socket

@data-client/graphql

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@data-client/graphql

Quickly define typed GraphQL resources and endpoints

latest
npmnpm
Version
0.15.2
Version published
Maintainers
1
Created
Source

Data Client for GraphQL

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

GraphQL Endpoints for Data Client

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

Data model
Data TypeMutableSchemaDescriptionQueryable
ObjectEntity, EntityMixin, GQLEntitysingle unique object
Union(Entity)polymorphic objects (A | B)
🛑Objectstatically known keys🛑
Invalidate(Entity)delete an entity🛑
ListCollection(Array)growable lists
🛑Arrayimmutable lists🛑
Alllist of all entities of a kind
MapCollection(Values)growable maps
🛑Valuesimmutable maps🛑
anyQuery(Queryable)memoized custom transforms

Keywords

GraphQL

FAQs

Package last updated on 05 Jan 2026

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