{"_id":"@bilgorajskim/ra-data-graphql","_rev":"3-18107f14f559a12c0e7c4fc322df89e7","name":"@bilgorajskim/ra-data-graphql","dist-tags":{"latest":"2.1.0-2"},"versions":{"2.1.0-0":{"name":"@bilgorajskim/ra-data-graphql","version":"2.1.0-0","description":"A GraphQL data provider for react-admin","main":"./lib/index.js","repository":{"type":"git","url":"git+https://github.com/marmelab/react-admin.git"},"bugs":{"url":"https://github.com/marmelab/react-admin/issues"},"homepage":"https://github.com/marmelab/react-admin#readme","authors":["Gildas Garcia"],"keywords":["reactjs","react","@bilgorajskim/react-admin","admin-on-rest","rest","graphql"],"license":"MIT","dependencies":{"apollo-client":"^2.2.8","apollo-client-preset":"^1.0.6","graphql-tag":"^2.6.1","lodash":"~4.17.5","pluralize":"~7.0.0"},"peerDependencies":{"@bilgorajskim/react-admin":"^2.0.4","graphql":"^0.13.2"},"devDependencies":{"@bilgorajskim/react-admin":"^2.1.0-0","graphql":"^0.13.2"},"publishConfig":{"access":"public"},"_id":"@bilgorajskim/ra-data-graphql@2.1.0-0","_npmVersion":"6.1.0","_nodeVersion":"10.4.0","_npmUser":{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"},"dist":{"integrity":"sha512-ae6x1yoL+KhaKw8RamBMHy0qHo3IYfTxaTW/9hTo0cF2Ia8ycqFtI4XaJR5Gvb0tPBk10GtIx+CeHOQj/ZR7cg==","shasum":"8091f34c73e777fd41781c895797565cc03fbddb","tarball":"https://registry.npmjs.org/@bilgorajskim/ra-data-graphql/-/ra-data-graphql-2.1.0-0.tgz","fileCount":7,"unpackedSize":22267,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbNwQXCRA9TVsSAnZWagAArcoP/0r0U/I47OMf1+/Wq6oL\nxi41g7Is47wVJA7+Icszm5Bql9NvD0dPawoCRUUlwLkWvIC8AgDlyTHmUljp\nac+Ft86nJ0M7gOJ/Dl9HVtedREzQrAWXUT4KpXdTs2ArzAbkkXJfQ2YNJfs1\nk99ADYdTqGjiH0pRSidrtHHH4mJ9plK6udcgU88PXPoPo/oH8fZvTP8bUvGI\nvWtwXGQJoL8OAu2O+7vENcr8oWGzSyCZAkZlHqRuglMw1rqJ9YXSs8Fw737C\nnpyxhjO960QLEq3BfJG3V/4gvPo5ZxVpOyhI+uUemV+kAzRqHtAzU5um/MFu\ndi+4dqkO5ZiK8QdAK8yQMlqGH3CCTbWPUMacYxYcRdpoqQNYMdjsr0pn54pZ\nFfarNSGBEargTUeobTe7TIdftI5kiwG4s8Eza29wx+5U0sHSkaP9G2Oh+uze\nPIkrBLk4fCEdJ9Zqisi/ao5Tyh18v+iC7K9CtkR4OJnCij9MaiWfSGJxMF5z\n7cBh1rql1nWq6MTr5Au5jgJolUYm1fVRMR0uqi5aNxWfc1QgRF6R/21kU6kZ\nj4locRdG60+cr5E3mrORYxBvLvSe6FaBazmimlsusUzNUaa1FYRN58xjagil\nSoDpkl/VnksX14Vrrit1waJTGi2NwJ6SmXxAIldiy0B4mstE3XOxfohBC5l8\nTBfy\r\n=cqlX\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC2Jv4AbIxEzF0r8r50sdMdloAUeO1ryTySsvC6OineVAiAZHisIkuf13croDGYcbkJ3Ai7MywGVxKVOGDg88XNZTg=="}]},"maintainers":[{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ra-data-graphql_2.1.0-0_1530332182997_0.0395062771966479"},"_hasShrinkwrap":false},"2.1.0-1":{"name":"@bilgorajskim/ra-data-graphql","version":"2.1.0-1","description":"A GraphQL data provider for react-admin","main":"./lib/index.js","repository":{"type":"git","url":"git+https://github.com/marmelab/react-admin.git"},"bugs":{"url":"https://github.com/marmelab/react-admin/issues"},"homepage":"https://github.com/marmelab/react-admin#readme","authors":["Gildas Garcia"],"keywords":["reactjs","react","@bilgorajskim/react-admin","admin-on-rest","rest","graphql"],"license":"MIT","dependencies":{"apollo-client":"^2.2.8","apollo-client-preset":"^1.0.6","graphql-tag":"^2.6.1","lodash":"~4.17.5","pluralize":"~7.0.0"},"peerDependencies":{"@bilgorajskim/react-admin":"^2.0.4","graphql":"^0.13.2"},"devDependencies":{"@bilgorajskim/react-admin":"^2.1.0-1","graphql":"^0.13.2"},"publishConfig":{"access":"public"},"_id":"@bilgorajskim/ra-data-graphql@2.1.0-1","_npmVersion":"6.1.0","_nodeVersion":"10.4.0","_npmUser":{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"},"dist":{"integrity":"sha512-cDf80+GOTCDxzmz3ikrWIFm+C8lOxj3X/Pg1/SPsoxr2alFtM4q9LojTNyBfLjK6YUe9Eko+hwNf+09xOwX7mA==","shasum":"4cb966c311e57127f554c0575b9470da65289423","tarball":"https://registry.npmjs.org/@bilgorajskim/ra-data-graphql/-/ra-data-graphql-2.1.0-1.tgz","fileCount":7,"unpackedSize":22267,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbNwXxCRA9TVsSAnZWagAAMwkP/2m9fTzSYqnvxFIP4wNV\nn40P1byNRNE/BdCnrFQHSXZurvCp+7AJDiNyBY0kdEcxEDDPOQtmGyU4MJES\nyye7PWx0urzfTumrsAq9/Uin3DtlRuAPDZFviK47t3qj6Of+mIcy3BwAcLgx\nMHKw/dMQh8JFYNwisopmPtt/Q2OkkJjYNelUHAE77ZmCpv0HWXYeAoirvHBD\nvkyQlxBmMmtXwgVNHQUrIBuUVYp7XCmJOD9H3yDMGbM+8wFAdJ3q7F7T+gbu\n1XkaLs1arnYTgPxkIYsHTTEZs0iIndv9ZgRwOmvUSC+L05DFQXyPT6xzwgWX\n2mW4VeMW2dsPvXmWrTMPyrHpfBOQqBSRMVtfqfdr8FCbyRfKmOc4sdBdPHP8\naDmWciG6he6TwACetuvYKvgMhrjpy4zmYCTejoKS4UhE/nmP/li2IHxnktoj\nZdvq4JIvUNndRXUScRUHtBi499RGgnd3F8es3zixf0p6Cy5DXJC/D2oW7Nyq\nWT8O2qfqdy95LKFxOK3sATlLLAwXKjDEsxTlcZpPOZONVRgANypQbKT238/w\nmnMTt+V/lyZgiLcVVSn04nkENkaUm3ju+RJSspdpNOO1xS6QWalzztHD8j46\nYJQCukQ7VPR+7aebAAiXP0XPVDqmtrsS7ZCKgRz11EdbLUvGR205Y0WY1vyL\nJIpp\r\n=BExt\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDhCR2MP2/8xiT6G9ku9QjFmBDLzaJM4o5uhOkcratsuAiEAy5WGAZov0yVKAGl+hJyuy2SZ3YK1qmbgEDtP1GdQvwc="}]},"maintainers":[{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ra-data-graphql_2.1.0-1_1530332657003_0.381608721602712"},"_hasShrinkwrap":false},"2.1.0-2":{"name":"@bilgorajskim/ra-data-graphql","version":"2.1.0-2","description":"A GraphQL data provider for react-admin","main":"./lib/index.js","repository":{"type":"git","url":"git+https://github.com/marmelab/react-admin.git"},"bugs":{"url":"https://github.com/marmelab/react-admin/issues"},"homepage":"https://github.com/marmelab/react-admin#readme","authors":["Gildas Garcia"],"keywords":["reactjs","react","@bilgorajskim/react-admin","admin-on-rest","rest","graphql"],"license":"MIT","dependencies":{"apollo-client":"^2.2.8","apollo-client-preset":"^1.0.6","graphql-tag":"^2.6.1","lodash":"~4.17.5","pluralize":"~7.0.0"},"peerDependencies":{"@bilgorajskim/react-admin":"^2.0.4","graphql":"^0.13.2"},"devDependencies":{"@bilgorajskim/react-admin":"^2.1.0-2","graphql":"^0.13.2"},"publishConfig":{"access":"public"},"_id":"@bilgorajskim/ra-data-graphql@2.1.0-2","_npmVersion":"6.1.0","_nodeVersion":"10.4.0","_npmUser":{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"},"dist":{"integrity":"sha512-vduI84T2JBe16rll7W41DENuWyNDrJgnE5/8GrCHBtg1YZcTgMCvMxPTw5mCSWpdVtRywK5/gQFI2xeuN3HfUA==","shasum":"6c389fc5f53ef101c8b7a8430cb481dabbcf479e","tarball":"https://registry.npmjs.org/@bilgorajskim/ra-data-graphql/-/ra-data-graphql-2.1.0-2.tgz","fileCount":7,"unpackedSize":22267,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbNwbJCRA9TVsSAnZWagAABucP/jfz1RammDFiFZnw1uBW\n2Pcdg/CGcC7Adiqv7IBegcAJov2yutJPcx7+8QzvHudsmh+o0rP/XQSCdZzX\nXqaVgRXygmGmrIFUWQ2XuM8feNgDZWpUXD3gM7nrvFkDA4wmAdkmrr1KEPc0\ntJxdiDp+uTRqT7pTkXGVV/G55QayxGT4SZXMhmqLFYQkX/i3TL+nSY1GeZ5q\nK2t0IIkvZtpPqcvdFB+xsUE6pO8zS6SK12LwrQ2lsIQwSIOSTTt7Zu6FfSIa\nmkMyX9wKalsbL4kXLRgi0NNHQfB1GDOlUFG/U7K0rA5eQF0fZYyqj6CCUePT\nTZm2arMknroCz5uKrCZpMpcBZ8CVTgciUskeuiUp43L0wSjpswzSnw8BOCfm\nt1+UhdSWq/y9gsu7jVTNd9IIE/z1EeEZxcnWVD0pGif7v6fIkxWsch+idTQT\n1Dtpurs+CX+mNYHuAZoodUnHEzH6I5utpZ+MzfyAD0G1lIFsKf2LSi2/jM45\nvI/YoMAKeV5l5730P7XiWBLJGnUiMz5vLVCsRYR8pLzi3MUba3C+2wxeuLwF\nvx00mNQl9jgrDQa9nbgwVu4oQeA/NXrDvFzMflNSeMSwJExvYJutBxhzov/j\n8ijcPfqhQY90mTU4pr12yivQ8wng0lkVhE4sMuMC30JPoNcUze+CZ22VPgkU\nX2rg\r\n=Lc3F\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDGs+wGRyPfCaBkGO0c31Hg5aKyriGtqSaml/JKqIpzzQIhAJThMpmYvqUFvsHPlyn2dEtH8ZXdmV+2n/S2IGreWZlM"}]},"maintainers":[{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ra-data-graphql_2.1.0-2_1530332873210_0.22242912904824408"},"_hasShrinkwrap":false}},"time":{"created":"2018-06-30T04:16:22.358Z","2.1.0-0":"2018-06-30T04:16:23.073Z","modified":"2022-04-04T18:48:37.648Z","2.1.0-1":"2018-06-30T04:24:17.103Z","2.1.0-2":"2018-06-30T04:27:53.299Z"},"maintainers":[{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"}],"description":"A GraphQL data provider for react-admin","homepage":"https://github.com/marmelab/react-admin#readme","keywords":["reactjs","react","@bilgorajskim/react-admin","admin-on-rest","rest","graphql"],"repository":{"type":"git","url":"git+https://github.com/marmelab/react-admin.git"},"bugs":{"url":"https://github.com/marmelab/react-admin/issues"},"license":"MIT","readme":"# ra-data-graphql\n\nA GraphQL data provider for [react-admin](https://github.com/marmelab/react-admin/)\nbuilt with [Apollo](http://www.apollodata.com/)\n\n- [Installation](#installation)\n- [Usage](#installation)\n- [Options](#options)\n\nThis is a very low level library which is not meant to be used directly unless you really want full control or are building a custom GraphQL data provider.\n\nIt provides the foundations for other GraphQL data provider packages such as `ra-data-graphcool` or `ra-data-graphql-simple`\n\n## About GraphQL and Apollo\n\nThis library is meant to be used with Apollo on the **client** side but\nyou're free to use any graphql **server**.\n\n## Installation\n\nInstall with:\n\n```sh\nnpm install --save graphql ra-data-graphql\n```\n\nor\n\n```sh\nyarn add graphql ra-data-graphql\n```\n\n## Usage\n\n```jsx\n// in App.js\nimport React, { Component } from 'react';\nimport buildGraphQLProvider from 'ra-data-graphql';\nimport { Admin, Resource, Delete } from 'react-admin';\n\nimport { PostCreate, PostEdit, PostList } from '../components/admin/posts';\n\nconst client = new ApolloClient();\n\nclass App extends Component {\n    constructor() {\n        super();\n        this.state = { dataProvider: null };\n    }\n    componentDidMount() {\n        buildGraphQLProvider()\n            .then(dataProvider => this.setState({ dataProvider }));\n    }\n\n    render() {\n        const { dataProvider } = this.state;\n\n        if (!dataProvider) {\n            return <div>Loading</div>;\n        }\n\n        return (\n            <Admin dataProvider={dataProvider}>\n                <Resource name=\"Post\" list={PostList} edit={PostEdit} create={PostCreate} remove={Delete} />\n            </Admin>\n        );\n    }\n}\n\nexport default App;\n```\n\n## Options\n\n### Customize the Apollo client\n\nYou can specify the client options by calling `buildGraphQLProvider` like this:\n\n```js\nimport { createNetworkInterface } from 'react-apollo';\n\nbuildGraphQLProvider({\n    client: {\n        networkInterface: createNetworkInterface({\n            uri: 'http://api.myproduct.com/graphql',\n        }),\n    },\n});\n```\n\nYou can pass any options supported by the [ApolloClient](http://dev.apollodata.com/core/apollo-client-api.html#apollo-client) contructor with the addition of `uri` which can be specified so that we create the network interface for you.\n\nYou can also supply your own [ApolloClient](http://dev.apollodata.com/core/apollo-client-api.html#apollo-client) instance directly with:\n\n```js\nbuildGraphQLProvider({ client: myClient });\n```\n\n### Introspection Options\n\nInstead of running an IntrospectionQuery you can also provide the IntrospectionQuery result directly. This speeds up the initial rendering of the `Admin` component as it no longer has to wait for the introspection query request to resolve.\n\n```jsx\nimport { __schema as schema } from './schema';\n\nconst introspectionOptions = {\n    schema\n};\n\nbuildGraphQLProvider({\n    introspection: introspectionOptions\n});\n```\n\nThe `./schema` file is a `schema.json` in `./scr` retrieved with [`get-graphql-schema --json <graphql_endpoint>`](https://github.com/graphcool/get-graphql-schema).\n\n> Note: Importing the `schema.json` file will significantly increase the bundle size.\n\n## Specify your queries and mutations\n\nFor the provider to know how to map react-admin request to apollo queries and mutations, you must provide a `queryBuilder` option. The `queryBuilder` is a factory function which will be called with the introspection query result.\n\nThe introspection result is an object with 3 properties:\n\n- `types`: an array of all the GraphQL types discovered on your endpoint\n- `queries`: an array of all the GraphQL queries and mutations discovered on your endpoint\n- `resources`: an array of objects with a `type` property, which is the GraphQL type for this resource, and a property for each react-admin fetch verb for which we found a matching query or mutation\n\nFor example:\n\n```js\n{\n    types: [\n        {\n            name: 'Post',\n            kind: 'OBJECT',\n            fields: [\n                { name: 'id', type: { kind: 'NON_NULL', ofType: { kind: 'SCALAR', name: 'ID' } } },\n                { name: 'title', type: { kind: 'NON_NULL', ofType: { kind: 'SCALAR', name: 'String' } } },\n                ...\n            ]\n        },\n        ...\n    ],\n    queries: [\n        {\n            name: 'createPost',\n            args: [\n                { name: 'title', type: { kind: 'NON_NULL', ofType: { kind: 'SCALAR', name: 'String' } } }\n            ],\n            type : { kind: 'OBJECT', name: 'Category' }\n        },\n        ...\n    ],\n    resources: [\n        {\n            type: {\n                name: 'Post',\n                kind: 'OBJECT',\n                fields: [\n                    { name: 'id', type: { kind: 'NON_NULL', ofType: { kind: 'SCALAR', name: 'ID' } } },\n                    { name: 'title', type: { kind: 'NON_NULL', ofType: { kind: 'SCALAR', name: 'String' } } },\n                    ...\n                ]\n            },\n            GET_LIST: {\n                name: 'createPost',\n                args: [\n                    { name: 'title', type: { kind: 'NON_NULL', ofType: { kind: 'SCALAR', name: 'String' } } }\n                ],\n                type : { kind: 'OBJECT', name: 'Category' }\n            },\n            ...\n        }\n    ]\n}\n```\n\nThe `queryBuilder` function must return a function which will be called with the same parameters as the react-admin data provider but must return an object matching the `options` of the ApolloClient [query](http://dev.apollodata.com/core/apollo-client-api.html#ApolloClient.query) method with an additional `parseResponse` function.\n\nThis `parseResponse` function will be called with an [ApolloQueryResult](http://dev.apollodata.com/core/apollo-client-api.html#ApolloQueryResult) and must returns the data expected by react-admin.\n\nFor example:\n\n```js\nimport buildFieldList from './buildFieldList';\n\nconst queryBuilder = introspectionResults => (raFetchType, resourceName, params) => {\n    const resource = introspectionResults.resource.find(r => r.type.name === resourceName);\n\n    switch (raFetchType) {\n        case 'GET_ONE':\n            return {\n                query: gql`query ${resource[raFetchType].name}($id: ID) {\n                    data: ${resource[raFetchType].name}(id: $id) {\n                        ${buildFieldList(introspectionResults, resource, raFetchType)}\n                    }\n                }`,\n                variables: params, // params = { id: ... }\n                parseResponse: response => response.data,\n            }\n            break;\n        // ... other types handled here\n    }\n}\n```\n\n```js\nbuildGraphQLProvider({ queryBuilder });\n```\n\n## Troubleshooting\n\n*When I create or edit a resource, the list or edit page does not refresh its data*\n\n`react-admin` maintain its own cache of resources data but, by default, so does the Apollo client. For every queries, we inject a default [`fetchPolicy`](http://dev.apollodata.com/react/api-queries.html#graphql-config-options-fetchPolicy) set to `network-only` so that the Apollo client always refetch the data when requested.\n\nDo not override this `fetchPolicy`.\n\n## Contributing\n\nRun the tests with this command:\n\n```sh\nmake test\n```\n","readmeFilename":"README.md"}