{"_id":"@davidmwhynot/ra-data-prisma-dataprovider","_rev":"1-28fe447a401b6dcbcc44be7c2495ccbd","name":"@davidmwhynot/ra-data-prisma-dataprovider","dist-tags":{"latest":"1.0.0"},"versions":{"0.0.1":{"name":"@davidmwhynot/ra-data-prisma-dataprovider","version":"0.0.1","author":{"name":"Marco Wettstein","email":"maw@panter.ch"},"license":"ISC","_id":"@davidmwhynot/ra-data-prisma-dataprovider@0.0.1","maintainers":[{"name":"davidmwhynot","email":"davidmwhynot@gmail.com"}],"contributors":[{"name":"David Whynot","email":"davidmwhynot@gmail.com"}],"homepage":"","dist":{"shasum":"233f714b77cb11ced9ca4fd692373272c27be14b","tarball":"https://registry.npmjs.org/@davidmwhynot/ra-data-prisma-dataprovider/-/ra-data-prisma-dataprovider-0.0.1.tgz","fileCount":186,"integrity":"sha512-ZQEW7POufawsrTTsB8AufZtiqvnCjFxhSO62KStfu12hyDtIIOHJO8ErGNjGswaNHfKbZidkiO81vumNdH+EPQ==","signatures":[{"sig":"MEUCICI80hHppJG4cGZVSv0MCrPXYO2YXYcAI+7KIF+1mz9MAiEA0xqdCEOefhFMcHZoGcxiW4dnC3Q18+CnT917G6jTGiA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":332840,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkB4voACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqdkQ//abnJ+y3Ktpx/ofDQf3SB85EfGbGeH99OVjPBERaj5SMTE7/i\r\n0cybVl30/7ve5qE0SssbsALvRmlb56HlXmaZL52gOlI0Mz1bhGepiOC3fLhy\r\nvoGHBp7L3Ez+HqoxhUBGLDb4wup4BJ76VarLUvoRmOpLu8MR4b74xASpLVaB\r\niOIKniBJDss+iVYrW/BLiG5E3z1fbcuJhEctwrgXDrpN5ePbtFqst/Laq+kS\r\ng8Y2U+4kmkhaFnCBdFwts0bVH3tMcmFw3z1asFwTKg7u8eTuw3C1ZkLI/TG4\r\n2oxPtZDDv3USxQGguIfTEfp5kybx8bfRUmOu/fxfz+KY7wsjKDx+iW0hpE30\r\noEzFjkQvF0jGtcuyPtoREPdL1Z6vgZRghXEaNsnJGBxCJ9pD7ygbT8KAOgcV\r\neRcyJnDUvedFmBLFiBPK7mhPcBD26x1DKpJlqvjEFaqTpSE/fH3KaieW2NM2\r\n5y3/JpxBGR/Yq0xmzkjzqRHlXXpj1Y38t1iQ5alJ2zt8N38L71jYCFTYpO07\r\njcBmXXji9f/tTAeOl3Mefyu3mq0iu4NRTMfNYfQeKJGpu4OiRfeNQk2ZoDBh\r\n4hs3Lg4w9u7VY9YtFKtyah4RRoFo1QkeBcufSze6D92oL3krJB8Kn7kf6O/X\r\navcpyQGVwqrJkiDVjoD4P6+BReSxh5qdEPA=\r\n=XnyD\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./lib/index.js","types":"./lib/index.d.ts","module":"./lib-es/index.js","gitHead":"a0686000448dee8ec4701b73fb9e7e4fdf12b845","scripts":{"test":"echo \"Error: run tests from root\" && exit 1","build":"yarn generate:test && yarn build:cjs && yarn build:es","build:es":"rimraf ./lib-es && tsc --project tsconfig.json","build:cjs":"rimraf ./lib && tsc --project tsconfig.json --outDir lib --module commonjs","generate:test":"yarn generate:test:prisma && yarn generate:test:nexus","generate:test:nexus":"yarn ts-node --project ../../tsconfig-test.json  --transpile-only test-data/buildTestSchemaNexus.ts","generate:test:prisma":"yarn prisma generate --schema test-data/datamodel.prisma"},"_npmUser":{"name":"davidmwhynot","email":"davidmwhynot@gmail.com"},"_npmVersion":"8.12.2","description":"> TODO: description","directories":{"lib":"lib-es","test":"__tests__"},"_nodeVersion":"16.15.1","dependencies":{"lodash":"^4.17.15","pluralize":"^8.0.0","@prisma/client":"3.2.1","ra-data-graphql":"3.11.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"prisma":"3.2.1","rimraf":"^3.0.2","ts-node":"~8.9.1","typescript":"^4.4.3","type-graphql":"~1.1.1","@types/pluralize":"^0.0.29","typegraphql-prisma":"~0.16.2"},"peerDependencies":{"react":"*","graphql":">=14.0.0","react-admin":"*","@prisma/client":"*","nexus-plugin-prisma":"^0.35.0"},"_npmOperationalInternal":{"tmp":"tmp/ra-data-prisma-dataprovider_0.0.1_1678216168573_0.7592816153829025","host":"s3://npm-registry-packages"}},"1.0.0":{"name":"@davidmwhynot/ra-data-prisma-dataprovider","version":"1.0.0","description":"> TODO: description","author":{"name":"Marco Wettstein","email":"maw@panter.ch"},"contributors":[{"name":"David Whynot","email":"davidmwhynot@gmail.com"}],"homepage":"","license":"ISC","main":"./lib/index.js","module":"./lib-es/index.js","types":"./lib/index.d.ts","directories":{"lib":"lib-es","test":"__tests__"},"publishConfig":{"access":"public"},"scripts":{"test":"echo \"Error: run tests from root\" && exit 1","build":"yarn generate:test && yarn build:cjs && yarn build:es","build:cjs":"rimraf ./lib && tsc --project tsconfig.json --outDir lib --module commonjs","build:es":"rimraf ./lib-es && tsc --project tsconfig.json","generate:test":"yarn generate:test:prisma && yarn generate:test:nexus","generate:test:prisma":"cross-env SKIP_PRISMA_VERSION_CHECK=1 yarn prisma generate --schema test-data/datamodel.prisma","generate:test:nexus":"yarn ts-node --project ../../tsconfig-test.json  --transpile-only test-data/buildTestSchemaNexus.ts"},"devDependencies":{"prisma":"^3.15.2","@types/pluralize":"^0.0.29","rimraf":"^3.0.2","ts-node":"~8.9.1","type-graphql":"^1.1.1","typegraphql-prisma":"^0.25.0","typescript":"^4.4.3","@prisma/client":"^3.15.2","nexus-plugin-prisma":"^0.35.0"},"dependencies":{"lodash":"^4.17.15","pluralize":"^8.0.0","ra-data-graphql":"3.11.4"},"peerDependencies":{"@prisma/client":"*","graphql":">=14.0.0","react":"*","react-admin":"*"},"gitHead":"216ba6ad26d3c180e4d9afe63f5b653ca63fdd10","_id":"@davidmwhynot/ra-data-prisma-dataprovider@1.0.0","_nodeVersion":"18.20.4","_npmVersion":"10.7.0","dist":{"integrity":"sha512-2TyaLSslA+bR9e418FCsZPZnldG5GcNWrijWuy5aY1Hc+RhqadvSLNyYZn23cCfN5SC4NMKPm6+faYgcCl6+mA==","shasum":"7af901ac23297c4115e243774e063cee248f6aa7","tarball":"https://registry.npmjs.org/@davidmwhynot/ra-data-prisma-dataprovider/-/ra-data-prisma-dataprovider-1.0.0.tgz","fileCount":194,"unpackedSize":346866,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD21nwX8vFbyM0rJv75Eii1yg4cFkLNN5SHxTCgo0LHIAIgNwh986nu43OIZbwIGMegIIn+Ttwq5oM4u+y/oZUvQVY="}]},"_npmUser":{"name":"davidmwhynot","email":"davidmwhynot@gmail.com"},"maintainers":[{"name":"davidmwhynot","email":"davidmwhynot@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ra-data-prisma-dataprovider_1.0.0_1729620239942_0.9129545525439393"},"_hasShrinkwrap":false}},"time":{"created":"2023-03-07T19:09:28.516Z","modified":"2024-10-22T18:04:00.379Z","0.0.1":"2023-03-07T19:09:28.797Z","1.0.0":"2024-10-22T18:04:00.173Z"},"author":{"name":"Marco Wettstein","email":"maw@panter.ch"},"license":"ISC","description":"> TODO: description","contributors":[{"name":"David Whynot","email":"davidmwhynot@gmail.com"}],"maintainers":[{"name":"davidmwhynot","email":"davidmwhynot@gmail.com"}],"readme":"# `@ra-data-prisma/dataprovider`\n\nData provider for [react admin](https://github.com/marmelab/react-admin)\n\n## Usage\n\n`yarn add @ra-data-prisma/dataprovider`\n\nMake sure your backend API is compatible by using the other package in this repo [backend](../backend/README.md).\nAlternativly, you can connect to a backend that was created using [typegraphql-prisma](https://www.npmjs.com/package/typegraphql-prisma). [See Chapter typegraphql-prisma](#usage-with-typegraphql-prisma)\n\nAdd the dataprovider to your react-admin app:\n\n```jsx\nimport React, { Component } from \"react\"\n\nimport { Admin, Resource, Datagrid, TextField, Login } from \"react-admin\"\nimport { useDataProvider } from \"@ra-data-prisma/dataprovider\"\nimport { UserList, UserEdit, UserCreate } from \"./resources/user\"\n\nimport useAuthProvider from \"./useAuthProvider\"\n\n\nconst AdminApp = () => {\n  const dataProvider = useDataProvider({\n    clientOptions: { uri: \"/graphql\" }\n    aliasPrefix: \"admin\" // 👈 set this, if you use a aliasPrefix on your backend as well (recommended)\n    filters: {} // custom filters\n    queryDialect: \"nexus-prisma\" // customize query dialect, defaults to nexus-prisma,\n  })\n  const authProvider = useAuthProvider()\n\n  if (!dataProvider) {\n    return <div>Loading</div>\n  }\n\n  return (\n    <Admin\n      dataProvider={dataProvider}\n      authProvider={authProvider}\n    >\n      <Resource\n        name=\"User\"\n        list={UserList}\n        edit={UserEdit}\n        create={UserCreate}\n      />\n    </Admin>\n  )\n}\n\nexport default AdminApp\n```\n\n## Features\n\n### aliasPrefix\n\nSet `aliasPrefix` if you have set it on the backend as well (see [backend](./packages/backend/README.md) ).\n\n### Search & Filtering\n\nthis dataprovider supports all filtering and searching and adds some convenience to it:\n\n- _intelligent handling of strings and ints_: you don't have to specify `equals` or `contains`, we do that for you. The filter can just be `{firstname: \"albert\"}` and we create the correct graphql query for that\n- _extended react-admin input fields_: you can directly use comparison operators on `NumberInputs`, `TextInputs` and `DateInputs`. For example, implementing \"Created since\" filter (`DateInput` on a field `createdAt`) would become\n  ```jsx\n  <DateInput label=\"Created since\" source=\"createdAt_gt\" />\n  ```\n  - available comparisons (default comparison is the one which would be used if omitted):\n    - ints, floats and datetimes - `gt`, `gte`, `lt`, `lte`, `equals` (default = `equals`)\n    - strings - `gt`, `gte`, `lt`, `lte`, `equals`, `contains`, `startsWith`, `endsWith` (default = `contains`)\n- _case insensitive_: If your Prisma version supports it (>= 2.8.0), we automatically query strings as case insensitive. If your Prisma version doesn't support it, we emulate it with query for multiple variations of the search term: as-is, fully lowercase, first letter uppercase. This does work in many cases (searching for terms and names), but fails in some.\n- _q_ query. `q` is a convention in react-admin for general search. We implement this client side. A query on `q` will search all string fields and int fields on a resource. It additionaly splits multiple search terms and does an AND search\n- if you need more sophisticated search, you can use normal nexus-prisma graphql queries. You can even mix it with `q` and the intelligent short notation\n\n### Custom filters\n\nif you have a complex query, you can define custom filters:\n\n```ts\n const dataProvider = useDataProvider({\n    clientOptions: { uri: \"/graphql\" }\n\n    filters: {\n      onlyMillenials: (value?: boolean) =>\n        value === true\n          ? {\n              AND: [\n                {\n                  yearOfBirth: {\n                    gte: 1981,\n                  },\n                },\n                {\n                  yearOfBirth: {\n                    lte: 1996,\n                  },\n                },\n              ],\n            }\n          : undefined,\n    },\n  })\n\n```\n\nThen you can use that in a react-admin filter:\n\n```tsx\nconst UserFilter = (props) => (\n  <Filter {...props}>\n    <TextInput label=\"Search\" source=\"q\" alwaysOn />\n    <BooleanInput\n      label=\"Show only millenials\"\n      source=\"onlyMillenials\"\n      alwaysOn\n    />\n  </Filter>\n);\n```\n\n**Notice** if you want to omit the filter, return null or undefined.\n\n### Relations\n\nIf you have relations, you can use `ReferenceArrayField/Input` or `Referenceinput/Field`. Make sure that the reference Model is also compatible (by calling `addCrudResolvers(\"MyReferenceModel\")` from `@ra-data-prisma/backend` on your backend).\n\nMake sure to add the suffix `_id` or `_ids` (if its an array field) to the `source` property.\n\n#### Examples:\n\n_show a list of cities with the country_\n\n```jsx\nexport const CityList = (props) => (\n  <List {...props}>\n    <Datagrid>\n      <TextField source=\"id\" />\n      <TextField source=\"name\" />\n      <ReferenceField\n        label=\"Country\"\n        source=\"country_id\" // <-- suffix _id\n        reference=\"Country\"\n      >\n        <TextField source=\"name\" />\n      </ReferenceField>\n      <EditButton />\n    </Datagrid>\n  </List>\n);\n```\n\n_show all user roles in the user list_\n\n```jsx\nexport const UserList = (props) => (\n  <List {...props}>\n    <Datagrid>\n      <TextField source=\"id\" />\n      <TextField source=\"username\" />\n      <ReferenceArrayField\n        alwaysOn\n        label=\"Roles\"\n        source=\"roles_ids\" // <-- suffix _ids because it is an array field\n        reference=\"UserRole\"\n      >\n        <SingleFieldList>\n          <ChipField source=\"name\" />\n        </SingleFieldList>\n      </ReferenceArrayField>\n      <EditButton />\n    </Datagrid>\n  </List>\n);\n```\n\n_edit the roles for a user_\n\n```jsx\nexport const UserEdit = (props) => (\n  <Edit title={<UserTitle />} {...props} undoable={false}>\n    <SimpleForm variant=\"outlined\">\n      <TextInput source=\"userName\" />\n      <ReferenceArrayInput\n        label=\"Roles\"\n        source=\"roles_ids\" // <-- suffix _ids because it is an array field\n        reference=\"UserRole\"\n        allowEmpty\n        fullWidth\n      >\n        <SelectArrayInput optionText=\"id\" />\n      </ReferenceArrayInput>\n    </SimpleForm>\n  </Edit>\n);\n```\n\n### Sorting by relations\n\n`<List />`s can be sorted by relations. [Enable it in the backend](../backend#enable-sort-by-relation)\n\n### Customize fetching & virtual Resources\n\nreact-admin has [no mechanism to tell the dataprovider which fields are requested for any resources](https://github.com/marmelab/react-admin/issues/4751),\nwe therefore load all fields for a resource. If a field points to an existing `Resource`, we only fetch the id of that resource.\n\nBut sometimes you need to customize this behaviour, e.g.:\n\n- you want to load a nested resource with all properties for easier export\n- you have large/slow resolvers in some resources and don't want to load these for performance reasons\n\nWe therefore provide a way to customize the loaded field-set by defining fragments, blacklists and whitelists.\n\nAdditionaly you can use that to create \"virtual resources\" that show other fields.\n\n#### Basic usage\n\nusing one fragment for both one and many:\n\n```ts\n\nbuildGraphQLProvider({\n  clientOptions: { uri: \"/api/graphql\" } as any,\n  resourceViews: {\n    <local resource name>: {\n      resource: <backend resource name>,\n      fragment: <fragment to use>\n    },\n  },\n});\n```\n\nYou can also specify different fragments for one and many (or ommit one of those):\n\n```ts\n\nbuildGraphQLProvider({\n  clientOptions: { uri: \"/api/graphql\" } as any,\n  resourceViews: {\n    <local resource name>: {\n      resource: <backend resource name>,\n      fragment: {\n        one: <fragment for one>\n        many: <fragment for many>\n      }\n    },\n  },\n});\n```\n\n- `<backend resource name>`: the name of an existing `Resource` that is defined on the backend\n- `<local resource name>`: if you use the same name as `<backend resource name>`, you basically customize that `Resource`. You can chose a different name\n  to create a \"virtual\" resource.\n- `<fragment for ...>`: Specifies which fields are loaded when fetching one or many records. See below for available fragment types\n- if you only specify `one` or `many`, it will fall back to the default behavior if either would be used.\n\nGotcha: when using different fragments for one and many, the detail view might be loaded with certain fields being `undefined`. [See this discussion](https://github.com/panter/ra-data-prisma/issues/40#issuecomment-779441155)\n\n#### Fragment type blacklist / whitelist\n\nUse this if you want to exclude certain fields (blacklist) or only include certain fields:\n\n```ts\n// whitelist\nbuildGraphQLProvider({\n  clientOptions: { uri: \"/api/graphql\" } as any,\n  resourceViews: {\n    Users: {\n      resource: \"Users\",\n      fragment: {\n        many: {\n          type: \"whitelist\",\n          fields: [\"id\", \"firstName\", \"lastName\"],\n        },\n      },\n    },\n  },\n});\n```\n\n```ts\n// blacklist\nbuildGraphQLProvider({\n  clientOptions: { uri: \"/api/graphql\" } as any,\n  resourceViews: {\n    Users: {\n      resource: \"Users\",\n      fragment: {\n        many: {\n          type: \"blacklist\",\n          fields: [\"roles\", \"avatarImage\"],\n        },\n      },\n    },\n  },\n});\n```\n\n#### Fragment type \"document\"\n\nYou can use graphql Fragments (DocumentNode) to presicely select fields.\nThis is more verbose than using blacklists / whitelists,\nbut enables you to deeply select fields. Additionaly your IDE can typecheck the fragment\n(e.g. when using the apollo extension in vscode).\n\nBy default, the fragment replaces the default fields.\n\n```ts\nimport gql from \"graphql-tag\";\n\nbuildGraphQLProvider({\n  clientOptions: { uri: \"/api/graphql\" } as any,\n  resourceViews: {\n    Users: {\n      resource: \"Users\",\n      fragment: {\n        many: {\n          type: \"document\",\n          // mode: \"replace\" <--- that is the default\n          doc: gql`\n            fragment OneUserWithTwitter on User {\n              id\n              firstName\n              lastName\n              userSocialMedia {\n                twitter\n              }\n            }\n          `,\n        },\n      },\n    },\n  },\n});\n```\n\nIf you want to extend the default fields with a fragment, use `mode: \"extend\"` instead:\n\n```ts\nimport gql from \"graphql-tag\";\n\nbuildGraphQLProvider({\n  clientOptions: { uri: \"/api/graphql\" } as any,\n  resourceViews: {\n    Users: {\n      resource: \"Users\",\n      fragment: {\n        many: {\n          type: \"document\",\n          mode: \"extend\" // <---\n          doc: gql`\n            fragment OneUserWithTwitter on User {\n              userSocialMedia {\n                twitter\n              }\n            }\n          `,\n        },\n      },\n    },\n  },\n});\n```\n\nthis will fetch all default fields plus the fields of the fragment. If the fragment declares a field with the same name as a default field, the fragment's field replaces the default one.\n\n#### Virtual Resources\n\nYou can use a different name for a resource, that does not exist on the backend:\n\n```ts\n// real world example\nbuildGraphQLProvider({\n  clientOptions: { uri: \"/api/graphql\" } as any,\n  resourceViews: {\n    ParticipantsToInvoice: {\n      resource: \"ChallengeParticipation\",\n      fragment: {\n        one: {\n          type: \"document\",\n          doc: gql`\n            fragment OneBilling on ChallengeParticipation {\n              challenge {\n                title\n              }\n              user {\n                email\n                firstname\n                lastname\n                school {\n                  name\n                  address\n                  city {\n                    name\n                    zipCode\n                    canton {\n                      id\n                    }\n                  }\n                }\n              }\n              teamsCount\n              teams {\n                name\n              }\n            }\n          `,\n        },\n        many: {\n          type: \"document\",\n          doc: gql`\n            fragment ManyBillings on ChallengeParticipation {\n              challenge {\n                title\n              }\n              user {\n                email\n                firstname\n                lastname\n                school {\n                  name\n                  address\n                }\n              }\n              teams {\n                name\n              }\n            }\n          `,\n        },\n      },\n    },\n  },\n});\n```\n\nNow you have a new virtual resource `ParticipantsToInvoice` that can be used to display a List or for one record. (notice: update/create/delete is currently not specified, so use it read-only) and it will have exactly this data.\n\nThere are two ways you can use this new virtual resource. If you want to use it with React-Admin's query hooks (`useQuery, useGetList, useGetOne`), you need to add this as a new `<Resource>`:\n\n```jsx\n<Admin>\n  // ...\n  <Resource name=\"ParticipantsToInvoice\" />\n</Admin>\n```\n\nThese hooks rely on Redux store and will throw an error if the resource isn't defined.\n\nHowever, if you directly use data provider calls, you can use it with defined `<Resource>` but also _without_ as it directly calls data provider.\n\n```ts\nconst dataProvider = useDataProvider(options);\nconst { data } = await dataProvider.getList(\"ParticipantsToInvoice\", {\n  pagination: { page: 1, perPage: 10 },\n  sort: { field: \"id\", order: \"ASC\" },\n  filter: {},\n});\n```\n\n### Customize input data on create / update (experimental)\n\nYou can alter the data sent to create / update mutations.\n\nE.g. Consider having a field `<TextField source=\"userEmail\" />`. `userEmail` does not exist on the Resource,\nbut you want to use this field to customize the data sent to the backend:\n\n```ts\nconst dataProvider = useDataProvider({\n  customizeInputData: {\n    MyResource: {\n      create: (data, params) => ({\n        ...data,\n        user: {\n          connectOrCreate: {\n            create: {\n              email: params.userEmail,\n            },\n            where: {\n              email: params.userEmail,\n            },\n          },\n        },\n      }),\n      update: // ...\n    },\n  },\n});\n```\n\n## Use without introspection\n\nthe dataprovider uses introspection in order to create the right queries for your backend.\nBut if you bundle the IntrospectionSchema or graphql schema, you can use it directly.\n\n### use the introspection schema\n\nyou can download a introspection schema (in the json format) with:\n\n`npx apollo schema:download --endpoint=http://localhost:3000 ./src/graphql-schema.json`\n\nand then:\n\n```\nimport schema from \"../graphql-schema.json\";\n\nuseDataProvider({\n // ...\n introspection: {\n   schema: schema.__schema\n }\n})\n```\n\n### use with graphql file:\n\nthis assumes that you can load and bundle the graphql file (e.g. with raw-loader):\n\n```\nimport { buildSchema, introspectionFromSchema } from \"graphql\";\n\n\nuseDataProvider({\n // ...\n introspection: {\n   schema: introspectionFromSchema(\n      buildSchema(\n        require(\"!!raw-loader!../schema.graphql\").default\n      )\n    ).__schema\n }\n})\n```\n\n## Usage with typegraphql-prisma\n\n(beta)\n\nYou can use the dataprovider to connect to a backend that was created using https://www.npmjs.com/package/typegraphql-prisma.\nIt has a slightly different dialect. Pass the following option to the dataprovider:\n\n```ts\nconst dataProvider = useDataProvider({\n    clientOptions: { uri: \"/graphql\" }\n    queryDialect: \"typegraphql\" // 👈\n})\n```\n\n### override mutation or query operation names due to prisma versions breaking changes\n\nYou can override operation names depending on the version of typegraphql-prisma you are using:\n\n```ts\nimport {\n  CREATE,\n  UPDATE,\n  DELETE,\n  GET_LIST,\n  GET_MANY,\n  GET_MANY_REFERENCE,\n  GET_ONE,\n} from \"react-admin\";\nimport { Options } from \"@ra-data-prisma/dataprovider\";\nimport camelCase from \"lodash/camelCase\";\nimport pluralize from \"pluralize\";\n\nconst options: Options = {\n  queryDialect: \"typegraphql\",\n  mutationOperationNames: {\n    typegraphql: {\n      [CREATE]: (resource) => `createOne${resource.name}`,\n      [UPDATE]: (resource) => `updateOne${resource.name}`,\n      [DELETE]: (resource) => `deleteOne${resource.name}`,\n    },\n  },\n  queryOperationNames: {\n    typegraphql: {\n      [GET_LIST]: (resource) => `${pluralize(camelCase(resource.name))}`,\n      [GET_MANY]: (resource) => `${pluralize(camelCase(resource.name))}`,\n      [GET_MANY_REFERENCE]: (resource) =>\n        `${pluralize(camelCase(resource.name))}`,\n      [GET_ONE]: (resource) => `${camelCase(resource.name)}`,\n    },\n  },\n};\n```\n\nIf you are using an alias prefix, be sure to include it in your custom operation names:\n\n```ts\nimport { CREATE, UPDATE, DELETE } from \"react-admin\";\nimport { Options, makePrefixedFullName } from \"@ra-data-prisma/dataprovider\";\n\nconst aliasPrefix = \"admin\";\n\nconst prefix = (s: string) => makePrefixedFullName(s, aliasPrefix);\n\nconst options: Options = {\n  aliasPrefix,\n  queryDialect: \"typegraphql\",\n  mutationOperationNames: {\n    typegraphql: {\n      [CREATE]: (resource) => prefix(`createOne${resource.name}`),\n      [UPDATE]: (resource) => prefix(`updateOne${resource.name}`),\n      [DELETE]: (resource) => prefix(`deleteOne${resource.name}`),\n    },\n  },\n  queryOperationNames: {\n    typegraphql: {\n      [GET_LIST]: (resource) =>\n        prefix(`${pluralize(camelCase(resource.name))}`),\n      [GET_MANY]: (resource) =>\n        prefix(`${pluralize(camelCase(resource.name))}`),\n      [GET_MANY_REFERENCE]: (resource) =>\n        prefix(`${pluralize(camelCase(resource.name))}`),\n      [GET_ONE]: (resource) => prefix(`${camelCase(resource.name)}`),\n    },\n  },\n};\n```\n\n## Usage with pothos-prisma\n\n(beta)\n\nYou can use the dataprovider to connect to a backend that was created using https://www.npmjs.com/package/@pothos/plugin-prisma-utils.\nIt has slightly different OrderBy values. Pass the following option to the dataprovider:\n\n```ts\nconst dataProvider = useDataProvider({\n    clientOptions: { uri: \"/graphql\" }\n    queryDialect: \"pothos-prisma\" // 👈\n})\n```\n","readmeFilename":"README.md"}