{"_id":"@bilgorajskim/ra-data-graphql-simple","_rev":"3-856a4d2b1c49587a09dfbf40923cf0b7","name":"@bilgorajskim/ra-data-graphql-simple","dist-tags":{"latest":"2.1.0-2"},"versions":{"2.1.0-0":{"name":"@bilgorajskim/ra-data-graphql-simple","version":"2.1.0-0","description":"A GraphQL simple 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":{"@bilgorajskim/ra-data-graphql":"^2.1.0-0","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-simple@2.1.0-0","_npmVersion":"6.1.0","_nodeVersion":"10.4.0","_npmUser":{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"},"dist":{"integrity":"sha512-0nlKW0Q8quXvclu9A10Jx1GNQNrkdeweII4/9jcVJO4BXCBQ9R1IIWjz75szY31mAgrWrLpn9wKMZT+NXngmbw==","shasum":"76876c0ae2579293faab85713c1fad46e9d21b1d","tarball":"https://registry.npmjs.org/@bilgorajskim/ra-data-graphql-simple/-/ra-data-graphql-simple-2.1.0-0.tgz","fileCount":21,"unpackedSize":73311,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbNwQsCRA9TVsSAnZWagAAy0EP/3sO/f4zTgbfkbm4vQ0J\n1qhU3RxK+8F27UJnS3uDN82JEvIySRJ3kEjw6QiYgCdnyrhW/MQzl2jHvbqq\npU/MEQi4CHuZJw+cYwkcNx8iYFGbSnv9sfGam4olOhxCxV2naTtLVD3EZmw2\npkx7OfHUu02l1CvKPT+oim6ykkV/WlE1BGbydPam3PvlrGD0Pcwkd+L2qXSK\nZtSCL/mgJPQ7TQHS4h7V+SfRceWFsHbL1qp5XgrOrKEQ8LTDXu9nQR9ueigt\nxSD9VYqQjmpGcvEizhrVjSXIXUCh1i2PaEumWSgybeaN7Jw8al5IVG0IVhwo\nnRVctmvmpzTbr1RpNuZ+sTIk4+asWmtSh1F2bSuFscCLoMMtxeif7CteZkXl\nRanP5Vd0fRsj9UlC10vMpwn3/8r84sXEwVqgIE139Ii/6vusDL/4Xwyiwmq8\nITLlMAWCEkalS+oXo0q+NVRW96KN07kaq6xWSYSGend7EnPDQ5TqZD/wg6kq\nLqAy4WMA7D8e1sfAsphXdhq1INLrYt8g2KE8EXymstuXdY4sygffQdJQBkSy\n7nnTJawEol0tZQ5XoI9QqglK2UXzl2+BMKqAHKLq9TvNoGdBGWgRnEuumHYz\nlylZlifYVarRhNfBUuqjkB8+tc9z9rN4GBNSb8yTtYg1UtM9t3qTW1lZuVmu\nDN9u\r\n=Xh6E\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCU6IpoYbbvlmV6+gbamGsVvtcHrUx1nkWC74vpi9ZpTAIgEcrXRBpRcBnIlKWQCYrDs3iaS9vyQjSHNrQguJzwhv8="}]},"maintainers":[{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ra-data-graphql-simple_2.1.0-0_1530332203889_0.6067014099351533"},"_hasShrinkwrap":false},"2.1.0-1":{"name":"@bilgorajskim/ra-data-graphql-simple","version":"2.1.0-1","description":"A GraphQL simple 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":{"@bilgorajskim/ra-data-graphql":"^2.1.0-1","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-simple@2.1.0-1","_npmVersion":"6.1.0","_nodeVersion":"10.4.0","_npmUser":{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"},"dist":{"integrity":"sha512-JHNYOpmsBf2NRbs+NcQPJkDL4fM3t9oNUmV0cBFZ2ve1IUlwELE3y2hz4c4uXrRaRJgOyYTgZoZO/9R4gb+51g==","shasum":"eaed8e49ade7f529c57150085be026349bcef584","tarball":"https://registry.npmjs.org/@bilgorajskim/ra-data-graphql-simple/-/ra-data-graphql-simple-2.1.0-1.tgz","fileCount":21,"unpackedSize":73311,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbNwYDCRA9TVsSAnZWagAA+BgP/0NNBieJe3TWVgFa5Tdq\nA6ZIyU/T7t4WzuYEPKD2smpENNFbbJLA3voJzTgN9/u7CiZ0i2V9QVRySCxr\n3Pa8wUwQym6Rh0aoVDowSjKTj7hqxBkoLzTUt/K06JQ+Ke64KniLImfuuYdC\nV4yy8GrbbYGdsYShwqpkaxDw81COV6mq+0szuYX8Hdm14WdlHC7DcgMCktz7\nnMKJpLWpZ0mbDzw1u3uTijXjK92KuXe1ANHxHibGpV1TbYr0YSgW7wehO4Am\nNn+I9T5FADFMEdBiTBR4YrTpxzB98h8kBXNlOBooflXN4gcf56AiGKxDt9ce\nbGyN9Hw49VrrMZAiJrlYd9hUDEELXqAJ/SCm/XSBOaLNXis6jvvtDI9y2XMf\nRtTlNGzsMUIVOhrG3EJtGqiquUPqiNvjvbvLczhnwZqp2jyhVx1wLKmL7d2u\nu5hiyWh8Bwj796Ssngl5uMHsOAKdciUluLT4wVeBZEAA7qzUEiTf3z1JIgVL\nIrWJDxI0UNDCWhBjlc8toUsmmnUdHYRstQX+6UT6MWfZCE+fRgWhChahgod8\ndj747XjDLClYJVLSSIcSs+SjPnfAHnsXVbpdJKyh0YXcfxH2XI0RSEVts7PU\nFzJ9ykQisXbtnPbj7WbxXQJD2VADiUtyuSpdPqZuDFONkHcHUcQ2nDrQUMRr\ncpJR\r\n=lcPQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCzHAxi3G9tiox/SKulzRPLAGjL8xpedCCuxcsiu746yQIgRVvMhnsZlCdkgz6oykU2npsrWuLwgANpONeQRfGl3EQ="}]},"maintainers":[{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ra-data-graphql-simple_2.1.0-1_1530332675136_0.40892259108177287"},"_hasShrinkwrap":false},"2.1.0-2":{"name":"@bilgorajskim/ra-data-graphql-simple","version":"2.1.0-2","description":"A GraphQL simple 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":{"@bilgorajskim/ra-data-graphql":"^2.1.0-2","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-simple@2.1.0-2","_npmVersion":"6.1.0","_nodeVersion":"10.4.0","_npmUser":{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"},"dist":{"integrity":"sha512-txeMmKaGnOJ0sWz1hCscIWaZW5knG3AbiVle+9zUAgC+Xl4QMXvVjyitwI1X1YkFNwzPQc3Ynyl3bIijKf1UJA==","shasum":"9e148c76c7f64753b7933f87f5cfa6a0b6eadaf6","tarball":"https://registry.npmjs.org/@bilgorajskim/ra-data-graphql-simple/-/ra-data-graphql-simple-2.1.0-2.tgz","fileCount":21,"unpackedSize":73311,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbNwbmCRA9TVsSAnZWagAAdsoP/3ZfopQVMLe9ekoeIS4T\nA9omFJ2yYn5iZVGiUeymqYejSr8XflvvtR6Y2Hbfb1ZKdIPn7zN3BrYaEgB1\n0BVeCCDyCdUlSEK5LhPFeQfjG7HftpfYdEhWJ5a//IVqyi0J1d0MLA+iJl7/\nuYoqMlM65zIAO1OqQCexRUJzq//m/GqVV0D4I7ZIgNuJFQJ3H90PdMi+Kq1j\nlJ9DaUulCa/5t83SYyveKvfUUpmh7sCH0udBiqIIf+WgdaF9uj24y4rylGMT\nQYniyazrd1bm6gKmm1Wmhy/BfADdpMobPeUib3zJXyQcQHCNSyYbrRK1TDmw\noqu9gi3Lg95l1wH4gSFOPsB0K29R/dRv5kILuSYwON3MO4rs3WyL3lLjSomp\nr0yXPcDJWoSldkiG+P4reVFLho8fcxAVT06+x+K4nz+Z5/2dJQ5/puCHJvuc\nyGxovioDtQV7kbe4XB3hHiY3XZOr7GeGKnYmw0Z4vxnf/SxL0z5werNm85P9\ntMaUCGFwQUk6IY82UEflVMP2bqKYIxpb6oS7u7FT2pCU+vtlCMQg03euljQ4\nVGz+TqOfOCnqJGkrnwKJmPK4LCfPnUzTIk0ixnSXc3EMeJgHD9+sWG3IJciZ\ni7WPMKH5tXu4+zkzDhxBKjoSC0e2YL/FXifXybl1NlGRj4/4TPmXQ5KjaXHl\n6Z6U\r\n=i6nZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCkLEHEbrxqjWfyxRmcAr73IgQvlBwkr9xdDMW1VWcE2QIhAOYxUpY3cJ1MYHydFlH0s8sSb67mCl1KPTSo6zVjJJrC"}]},"maintainers":[{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ra-data-graphql-simple_2.1.0-2_1530332902002_0.44603362420043036"},"_hasShrinkwrap":false}},"time":{"created":"2018-06-30T04:16:43.563Z","2.1.0-0":"2018-06-30T04:16:44.022Z","modified":"2022-04-04T18:48:37.845Z","2.1.0-1":"2018-06-30T04:24:35.226Z","2.1.0-2":"2018-06-30T04:28:22.065Z"},"maintainers":[{"name":"bilgorajskim","email":"bilgorajskim@gmail.com"}],"description":"A GraphQL simple 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-simple\n\nA GraphQL data provider for [react-admin](https://github.com/marmelab/react-admin/)\nbuilt with [Apollo](http://www.apollodata.com/) and tailored to target a simple GraphQL implementation.\n\n- [Installation](#installation)\n- [Usage](#installation)\n- [Options](#options)\n\n## Installation\n\nInstall with:\n\n```sh\nnpm install --save graphql ra-data-graphql-simple\n```\n\nor\n\n```sh\nyarn add graphql ra-data-graphql-simple\n```\n\n## Usage\n\nThe `ra-data-graphql-simple` package exposes a single function, which is a constructor for a `dataProvider` based on a GraphQL endpoint. When executed, this function calls the GraphQL endpoint, running an [introspection](http://graphql.org/learn/introspection/) query. It uses the result of this query (the GraphQL schema) to automatically configure the `dataProvider` accordingly.\n\n```js\n// in App.js\nimport React, { Component } from 'react';\nimport buildGraphQLProvider from 'ra-data-graphql-simple';\nimport { Admin, Resource, Delete } from 'react-admin';\n\nimport { PostCreate, PostEdit, PostList } from './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({ clientOptions: { uri: 'http://localhost:4000' }})\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## Expected GraphQL Schema\n\nThe `ra-data-graphql-simple` function works against GraphQL servers that respect a certain GraphQL grammar. For instance, to handle all the actions on a `Post` resource, the GraphQL endpoint should support the following schema:\n\n```gql\ntype Query {\n  Post(id: ID!): Post\n  allPosts(page: Int, perPage: Int, sortField: String, sortOrder: String, filter: PostFilter): [Post]\n  _allPostsMeta(page: Int, perPage: Int, sortField: String, sortOrder: String, filter: PostFilter): ListMetadata\n}\n\ntype Mutation {\n  createPost(\n    title: String!\n    views: Int!\n    user_id: ID!\n    User: User\n    Comments: [Comment]\n  ): Post\n  updatePost(\n    id: ID!\n    title: String!\n    views: Int!\n    user_id: ID!\n    User: User\n    Comments: [Comment]\n  ): Post\n  deletePost(id: ID!): Boolean\n}\n\ntype Post {\n    id: ID!\n    title: String!\n    views: Int!\n    user_id: ID!\n    User: User\n    Comments: [Comment]\n}\n\ntype PostFilter {\n    q: String\n    id: ID\n    title: String\n    views: Int\n    views_lt: Int\n    views_lte: Int\n    views_gt: Int\n    views_gte: Int\n    user_id: ID\n}\n\ntype ListMetadata {\n    count: Int!\n}\n\nscalar Date\n```\n\nThis is the grammar used e.g. by [marmelab/json-graphql-server](https://github.com/marmelab/json-graphql-server), a client-side GraphQL server used for test purposes.\n\n## Options\n\n### Customize the Apollo client\n\nYou can either supply the client options by calling `buildGraphQLProvider` like this:\n\n```js\nbuildGraphQLProvider({ clientOptions: { uri: 'http://localhost:4000', ...otherApolloOptions } });\n```\n\nOr supply your client directly with:\n\n```js\nbuildGraphQLProvider({ client: myClient });\n```\n\n### Customize the introspection\n\nThese are the default options for introspection:\n\n```js\nconst introspectionOptions = {\n    include: [], // Either an array of types to include or a function which will be called for every type discovered through introspection\n    exclude: [], // Either an array of types to exclude or a function which will be called for every type discovered through introspection\n}\n\n// Including types\nconst introspectionOptions = {\n    include: ['Post', 'Comment'],\n};\n\n// Excluding types\nconst introspectionOptions = {\n    exclude: ['CommandItem'],\n};\n\n// Including types with a function\nconst introspectionOptions = {\n    include: type => ['Post', 'Comment'].includes(type.name),\n};\n\n// Including types with a function\nconst introspectionOptions = {\n    exclude: type => !['Post', 'Comment'].includes(type.name),\n};\n```\n\n**Note**: `exclude` and `include` are mutualy exclusives and `include` will take precendance.\n\n**Note**: When using functions, the `type` argument will be a type returned by the introspection query. Refer to the [introspection](http://graphql.org/learn/introspection/) documentation for more information.\n\nPass the introspection options to the `buildApolloProvider` function:\n\n```js\nbuildApolloProvider({ introspection: introspectionOptions });\n```\n\n## `DELETE_MANY` and `UPDATE_MANY` Optimizations\n\nYou GraphQL backend may not allow multiple deletions or updates in a single query. This provider simply makes multiple requests to handle those. This is obviously not ideal but can be alleviated by supplying your own `ApolloClient` which could use the [apollo-link-batch-http](https://www.apollographql.com/docs/link/links/batch-http.html) link if your GraphQL backend support query batching.\n\n## Contributing\n\nRun the tests with this command:\n\n```sh\nmake test\n```\n","readmeFilename":"README.md"}