@crudx/graphql-apollo-adapter
v1.0.2
Published
Apollo Client transport adapter for [`@crudx/core`](../core/README.md).
Maintainers
Readme
@crudx/graphql-apollo-adapter
Apollo Client transport adapter for @crudx/core.
@crudx/core is transport-agnostic — it consumes any hook that matches
its TransportQueryHook / TransportMutationHook contract. Apollo's
generated hooks already satisfy that contract, so this package is a
thin typing layer + a few identity helpers that make the wiring
explicit at the call site.
Install
yarn add @crudx/graphql-apollo-adapter @crudx/core @crudx/common \
react react-dom \
axios currency-symbol-map dayjs lodash numeral \
@apollo/client graphqlEverything from react onward is a peer dependency. @apollo/client
and graphql are required so the adapter shares your existing Apollo
client; the rest come from @crudx/{core,common}'s helpers (date /
currency / numeric formatters, axios, lodash). Yarn 1 won't pull peer
deps automatically — install them all explicitly.
Usage
import { CRUD } from '@crudx/core';
import { graphqlGet, graphqlList, graphqlMutation } from '@crudx/graphql-apollo-adapter';
import {
useBankListingQuery,
useBankDetailLazyQuery,
useBankCreateMutation,
useBankUpdateMutation,
useBankDeleteMutation,
} from './graphql';
const bank = new CRUD('bank', {
list: { key: 'BankListing', query: graphqlList(useBankListingQuery) },
get: { key: 'BankDetail', query: graphqlGet(useBankDetailLazyQuery) },
create: { key: 'BankCreate', query: graphqlMutation(useBankCreateMutation) },
update: { key: 'BankUpdate', query: graphqlMutation(useBankUpdateMutation) },
delete: { key: 'BankDelete', query: graphqlMutation(useBankDeleteMutation) },
});Passing raw Apollo hooks (without the helpers) also works — they already satisfy the transport contract. The helpers are an opt-in clarity affordance.
Why a separate package?
Splitting the GraphQL/Apollo specifics out of @crudx/core lets the
core stay lean and lets us ship parallel adapters
(@crudx/rest-tanstack-adapter is already shipping;
@crudx/rest-swr-adapter is on the roadmap) without forcing every
consumer to install Apollo.
