Registry / database / ra-data-graphql-simple

ra-data-graphql-simple

JSON →
library5.14.7jsnpmunverified

A GraphQL data provider for react-admin (v5.x) built with Apollo Client, tailored for simple GraphQL APIs that follow a specific grammar (e.g., marmelab/json-graphql-server). It auto-configures CRUD operations via introspection queries. The package is actively maintained alongside react-admin, with releases matching the main library. Differentiators: zero-config setup for simple schemas, supports filtering with operators like _lt, _gt, and bulk updates. v5 is ESM-only, requires GraphQL >=15.6 and ra-core >=5.0.

npm install ra-data-graphql-simple
INSTALL
IMPORT
SIG · RA-DATA-GRAPHQL-SI
R
ra-data-graphql-simple
databasejavascriptv5.14.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

buildGraphQLProvider
import buildGraphQLProvider from 'ra-data-graphql-simple'
const buildGraphQLProvider = require('ra-data-graphql-simple')
ESM-only since v5; default export, not named.
buildQuery
import { buildQuery } from 'ra-data-graphql-simple'
import buildQuery from 'ra-data-graphql-simple'
Named export, for overriding specific queries.
Introduce types (TypeScript)
import type { BuildQuery } from 'ra-data-graphql-simple'
Package ships TypeScript types; use import type for type-only imports.

Shows async initialization of the GraphQL data provider with Apollo client options and integration into react-admin.

import React from 'react'; import { Admin, Resource } from 'react-admin'; import buildGraphQLProvider from 'ra-data-graphql-simple'; import { PostList, PostEdit, PostCreate } from './posts'; const dataProvider = await buildGraphQLProvider({ clientOptions: { uri: process.env.GRAPHQL_URI ?? 'http://localhost:4000/graphql' }, }); const App = () => ( <Admin dataProvider={dataProvider}> <Resource name="Post" list={PostList} edit={PostEdit} create={PostCreate} /> </Admin> ); export default App;
Debug
Known issues
breakingBuildQuery param order changed: 'fetchType' and 'resource' swapped in v4 'buildQuery' returns GET_LIST queries with different field selection Require a manual update if upgrading from v3
fix
Update custom buildQuery wrappers to match new signature: (fetchType, resource, params) => ...
affects: >=4.0.0 <5.0.0
deprecatedThe function 'buildGraphQLProvider' no longer accepts a callback; it always returns a Promise. Options like 'client' and 'clientOptions' changed their shape in v5.
fix
Use async/await or .then() to get the data provider. Pass options directly as object.
affects: >=5.0.0
gotchaThe introspection query may fail if the GraphQL endpoint requires authentication. No built-in way to pass auth token to Apollo Client by default.
fix
Create a custom ApolloClient with auth middleware and pass via client option: buildGraphQLProvider({ client: myClient })
affects: >=1.0.0
gotchaReferences: The parser generates additional `.id` properties for relation fields (e.g., author.id). You must use those in source props for ReferenceField, not the raw field name.
fix
Use <ReferenceField source="author.id" reference="User"> instead of source="author".
affects: >=1.0.0
breakingPackage became ESM-only in v5. CommonJS (require()) fails.
fix
Switch to import syntax. If using CommonJS, use dynamic import: const pkg = await import('ra-data-graphql-simple');
affects: >=5.0.0
Errors
Common errors & fixes
Cannot find module 'graphql'
Missing peer dependency graphql
fix
npm install graphql
Cannot use import statement outside a module
Using ESM import in a CommonJS project without type:module
fix
Add "type": "module" to package.json or use dynamic import: const pkg = await import('ra-data-graphql-simple');
buildGraphQLProvider is not a function
Importing named export instead of default (e.g., import { buildGraphQLProvider } from 'ra-data-graphql-simple')
fix
Use default import: import buildGraphQLProvider from 'ra-data-graphql-simple'
TypeError: Cannot read property 'introspection' of undefined
Failed introspection query (network error, auth required, or invalid endpoint)
fix
Check clientOptions.uri and ensure the endpoint is reachable; if auth needed, pass a custom client with auth middleware
Upgrade
Version history
5.14.7latest on npm
Audit
Dependencies
graphqlrequiredPeer dependency; required for introspection and query building
ra-corerequiredPeer dependency; core react-admin library
Agent activity
17 hits · last 30 days
node
14
Meta
1
Resources
ra-data-graphql-simple — npm install ra-data-graphql-simple · libregistry