How to use ra-data-graphql-simple - 4 common examples

To help you get started, we’ve selected a few ra-data-graphql-simple examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bootstrap-styled / ra-ui / examples / demo / src / dataProvider / graphql.js View on Github external
case 'commands':
                return 'Command';

            case 'products':
                return 'Product';

            case 'reviews':
                return 'Review';

            default:
                throw new Error(`Unknown resource ${resource}`);
        }
    };

    return buildApolloClient({
        clientOptions: {
            uri: 'http://localhost:4000/graphql',
        },
    }).then(dataProvider => (type, resource, params) =>
        dataProvider(type, getGqlResource(resource), params)
    );
};
github marmelab / react-admin / examples / demo / src / dataProvider / graphql.js View on Github external
export default () => {

    return buildApolloClient({
        clientOptions: {
            uri: 'http://localhost:4000/graphql',
        },
        introspection: {
            operationNames: {
                [DELETE]: resource => `remove${resource.name}`
            }
        },
        buildQuery: customBuildQuery
    }).then(dataProvider => (type, resource, params) =>
        dataProvider(type, getGqlResource(resource), params)
    );
};
github marmelab / react-admin / examples / demo / src / dataProvider / graphql.js View on Github external
const customBuildQuery = introspectionResults => {
    const buildQuery = buildQueryFactory(introspectionResults);

    return (type, resource, params) => {
        if (type === DELETE) {
            return {
                query: gql`mutation remove${resource}($id: ID!) {
                    remove${resource}(id: $id)
                }`,
                variables: { id: params.id },
                parseResponse: ({ data }) => {
                    if (data[`remove${resource}`]) {
                        return { data: { id: params.id } };
                    }

                    throw new Error(`Could not delete ${resource}`);
                }
            }
github mgm-interns / team-radio / admin / src / dataProvider / graphql.ts View on Github external
case 'songs':
        return 'Song';

      case 'playlistSongs':
        return 'PlaylistSong';

      case 'historySongs':
        return 'HistorySong';

      default:
        throw new Error(`Unknown resource ${resource}`);
    }
  };

  return buildApolloClient({
    clientOptions: {
      link: authLink.concat(httpLink),
      cache: new InMemoryCache()
    }
  })
    .then((dataProvider: any) => (type: any, resource: string, params: any) =>
      dataProvider(type, getGqlResource(resource), params)
    )
    .catch(() => {
      localStorage.clear();
      window.location.reload();
    });
};

ra-data-graphql-simple

A GraphQL simple data provider for react-admin

MIT
Latest version published 21 days ago

Package Health Score

93 / 100
Full package analysis