From b738dd50579c3e493e9976677c3fe46159ba326a Mon Sep 17 00:00:00 2001 From: gh-actions Date: Wed, 18 Oct 2023 13:47:10 +0000 Subject: [PATCH] Deploy website Deploy website version based on 89a2ad270ca0704266e0bf6c2e1d52956247c472 --- 404.html | 4 ++-- assets/js/332c17cc.0b5eb393.js | 1 + assets/js/332c17cc.c79706bf.js | 1 - .../js/{935f2afb.797c9d79.js => 935f2afb.156e9628.js} | 2 +- ...time~main.a571bf35.js => runtime~main.dd4d087e.js} | 2 +- docs/advanced/adding-fields/index.html | 4 ++-- docs/advanced/additional-decorators/index.html | 4 ++-- docs/advanced/custom-operations/index.html | 4 ++-- docs/advanced/custom-prisma-context-key/index.html | 4 ++-- docs/advanced/custom-prisma-import/index.html | 4 ++-- docs/advanced/emit-blocks/index.html | 4 ++-- docs/advanced/emit-id-type/index.html | 4 ++-- docs/advanced/emit-is-abstract/index.html | 4 ++-- docs/advanced/emit-redundant-types-info/index.html | 4 ++-- docs/advanced/exposing-actions/index.html | 4 ++-- docs/advanced/exposing-models/index.html | 4 ++-- docs/advanced/hiding-field/index.html | 4 ++-- docs/advanced/override-plural/index.html | 4 ++-- docs/advanced/overriding-object-decorator/index.html | 4 ++-- docs/advanced/renaming-field/index.html | 4 ++-- docs/advanced/renaming-model/index.html | 4 ++-- docs/advanced/simple-inputs/index.html | 4 ++-- docs/advanced/simple-resolvers/index.html | 4 ++-- docs/advanced/unchecked-scalars/index.html | 4 ++-- docs/basics/configuration/index.html | 4 ++-- docs/basics/installation/index.html | 11 ++++++----- docs/basics/nest-js/index.html | 4 ++-- docs/basics/prisma-version/index.html | 4 ++-- docs/basics/usage/index.html | 4 ++-- docs/category/advanced/index.html | 4 ++-- docs/category/basics/index.html | 6 +++--- docs/examples/index.html | 4 ++-- docs/intro/index.html | 4 ++-- index.html | 4 ++-- search/index.html | 4 ++-- 35 files changed, 70 insertions(+), 69 deletions(-) create mode 100644 assets/js/332c17cc.0b5eb393.js delete mode 100644 assets/js/332c17cc.c79706bf.js rename assets/js/{935f2afb.797c9d79.js => 935f2afb.156e9628.js} (90%) rename assets/js/{runtime~main.a571bf35.js => runtime~main.dd4d087e.js} (97%) diff --git a/404.html b/404.html index 5d810c00..7c626078 100644 --- a/404.html +++ b/404.html @@ -4,13 +4,13 @@ Page Not Found | TypeGraphQL Prisma - +
Skip to main content

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

- + \ No newline at end of file diff --git a/assets/js/332c17cc.0b5eb393.js b/assets/js/332c17cc.0b5eb393.js new file mode 100644 index 00000000..d2691f82 --- /dev/null +++ b/assets/js/332c17cc.0b5eb393.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunktypegraphql_prisma_website=self.webpackChunktypegraphql_prisma_website||[]).push([[370],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var p=a.createContext({}),l=function(e){var t=a.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=l(e.components);return a.createElement(p.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},u=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,p=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=l(n),m=r,h=u["".concat(p,".").concat(m)]||u[m]||d[m]||i;return n?a.createElement(h,o(o({ref:t},c),{},{components:n})):a.createElement(h,o({ref:t},c))}));function m(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,o=new Array(i);o[0]=u;var s={};for(var p in t)hasOwnProperty.call(t,p)&&(s[p]=t[p]);s.originalType=e,s.mdxType="string"==typeof e?e:r,o[1]=s;for(var l=2;l{n.r(t),n.d(t,{assets:()=>p,contentTitle:()=>o,default:()=>d,frontMatter:()=>i,metadata:()=>s,toc:()=>l});var a=n(7462),r=(n(7294),n(3905));const i={title:"Installation",sidebar_position:1},o=void 0,s={unversionedId:"basics/installation",id:"basics/installation",title:"Installation",description:"Be aware that due to usage of some ES2022 and newer Node.js features, you also have to use Node.js v16.13.0 or newer.",source:"@site/../docs/basics/installation.md",sourceDirName:"basics",slug:"/basics/installation",permalink:"/docs/basics/installation",draft:!1,editUrl:"https://github.com/MichalLytek/typegraphql-prisma/edit/main/docs/../docs/basics/installation.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{title:"Installation",sidebar_position:1},sidebar:"docs",previous:{title:"Basics",permalink:"/docs/category/basics"},next:{title:"Configuration",permalink:"/docs/basics/configuration"}},p={},l=[{value:"TypeGraphQL",id:"typegraphql",level:3},{value:"typegraphql-prisma generator",id:"typegraphql-prisma-generator",level:3},{value:"Additional dependencies",id:"additional-dependencies",level:3},{value:"TypeScript configuration",id:"typescript-configuration",level:3}],c={toc:l};function d(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("admonition",{type:"info"},(0,r.kt)("p",{parentName:"admonition"},"Be aware that due to usage of some ES2022 and newer Node.js features, you also have to use ",(0,r.kt)("strong",{parentName:"p"},"Node.js v16.13.0 or newer"),".")),(0,r.kt)("h3",{id:"typegraphql"},"TypeGraphQL"),(0,r.kt)("p",null,"First of all, you should perform all the steps described in the TypeGraphQL installation instruction:"),(0,r.kt)("p",null,(0,r.kt)("a",{parentName:"p",href:"https://typegraphql.com/docs/installation.html"},"https://typegraphql.com/docs/installation.html")),(0,r.kt)("h3",{id:"typegraphql-prisma-generator"},(0,r.kt)("inlineCode",{parentName:"h3"},"typegraphql-prisma")," generator"),(0,r.kt)("p",null,"After that, you have to install the generator, as a dev dependency:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"npm i -D typegraphql-prisma\n")),(0,r.kt)("p",null,"Furthermore, ",(0,r.kt)("inlineCode",{parentName:"p"},"typegraphql-prisma")," requires Prisma to work properly, so please install Prisma dependencies if you don't have it already installed:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"npm i -D prisma\nnpm i @prisma/client\n")),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"Be aware that ",(0,r.kt)("inlineCode",{parentName:"p"},"typegraphql-prisma")," is designed to work with a selected versions of Prisma.\nThis generator is designed to work and tested with the features of the ",(0,r.kt)("inlineCode",{parentName:"p"},"5.0.0")," release."),(0,r.kt)("p",{parentName:"admonition"},"You can update both ",(0,r.kt)("inlineCode",{parentName:"p"},"prisma")," and ",(0,r.kt)("inlineCode",{parentName:"p"},"@prisma/client")," to a newer version, matching ",(0,r.kt)("inlineCode",{parentName:"p"},"^5.0.0"),", like ",(0,r.kt)("inlineCode",{parentName:"p"},"5.4.2"),", in order to receive important bugfixes.\nHowever, make sure you don't use the new features from a newer Prisma version, especially the ones behind a preview flag."),(0,r.kt)("p",{parentName:"admonition"},"If you encounter a new Prisma feature not supported yet, please check on GitHub issues and create a new issue, if that wasn't already reported, and downgrade the Prisma version, if needed.")),(0,r.kt)("h3",{id:"additional-dependencies"},"Additional dependencies"),(0,r.kt)("p",null,"You also need to install the GraphQL Scalars library (to support the Prisma ",(0,r.kt)("inlineCode",{parentName:"p"},"Json"),", ",(0,r.kt)("inlineCode",{parentName:"p"},"BigInt")," and ",(0,r.kt)("inlineCode",{parentName:"p"},"Byte")," types):"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"npm i graphql-scalars\n")),(0,r.kt)("p",null,"In order to properly support the aggregate and group by queries, the ",(0,r.kt)("inlineCode",{parentName:"p"},"graphql-fields")," package is used, so it also has to be installed:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"npm i graphql-fields @types/graphql-fields\n")),(0,r.kt)("p",null,"Finally, please also install the ",(0,r.kt)("inlineCode",{parentName:"p"},"tslib")," package, which is required for ",(0,r.kt)("a",{parentName:"p",href:"/docs/advanced/additional-decorators"},"applying the additional decorators")," properly:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"npm i tslib\n")),(0,r.kt)("h3",{id:"typescript-configuration"},"TypeScript configuration"),(0,r.kt)("p",null,"As prisma emits multiple files, make sure you have your tsconfig set properly to ",(0,r.kt)("inlineCode",{parentName:"p"},'"module": "commonjs"'),":"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-json",metastring:"{4}","{4}":!0},'{\n "compilerOptions": {\n "target": "es2022",\n "module": "commonjs",\n "lib": ["es2022"],\n "experimentalDecorators": true,\n "emitDecoratorMetadata": true\n }\n}\n')),(0,r.kt)("p",null,"Otherwise you may experience runtime errors like ",(0,r.kt)("inlineCode",{parentName:"p"},"ReferenceError: Cannot access 'BankAccountWhereInput' before initialization"),".\nIt's because those generated files rely on each other, so ",(0,r.kt)("inlineCode",{parentName:"p"},"commonjs")," is needed to handle that cyclic imports."))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/332c17cc.c79706bf.js b/assets/js/332c17cc.c79706bf.js deleted file mode 100644 index b44a897f..00000000 --- a/assets/js/332c17cc.c79706bf.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunktypegraphql_prisma_website=self.webpackChunktypegraphql_prisma_website||[]).push([[370],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>u});var a=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var p=a.createContext({}),s=function(e){var t=a.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=s(e.components);return a.createElement(p.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},m=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,p=e.parentName,c=l(e,["components","mdxType","originalType","parentName"]),m=s(n),u=r,h=m["".concat(p,".").concat(u)]||m[u]||d[u]||i;return n?a.createElement(h,o(o({ref:t},c),{},{components:n})):a.createElement(h,o({ref:t},c))}));function u(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,o=new Array(i);o[0]=m;var l={};for(var p in t)hasOwnProperty.call(t,p)&&(l[p]=t[p]);l.originalType=e,l.mdxType="string"==typeof e?e:r,o[1]=l;for(var s=2;s{n.r(t),n.d(t,{assets:()=>p,contentTitle:()=>o,default:()=>d,frontMatter:()=>i,metadata:()=>l,toc:()=>s});var a=n(7462),r=(n(7294),n(3905));const i={title:"Installation",sidebar_position:1},o=void 0,l={unversionedId:"basics/installation",id:"basics/installation",title:"Installation",description:"Be aware that due to usage of some ES2019 and newer Node.js features, you also have to use Node.js v12.4.0 or newer.",source:"@site/../docs/basics/installation.md",sourceDirName:"basics",slug:"/basics/installation",permalink:"/docs/basics/installation",draft:!1,editUrl:"https://github.com/MichalLytek/typegraphql-prisma/edit/main/docs/../docs/basics/installation.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{title:"Installation",sidebar_position:1},sidebar:"docs",previous:{title:"Basics",permalink:"/docs/category/basics"},next:{title:"Configuration",permalink:"/docs/basics/configuration"}},p={},s=[{value:"TypeGraphQL",id:"typegraphql",level:3},{value:"typegraphql-prisma generator",id:"typegraphql-prisma-generator",level:3},{value:"Additional dependencies",id:"additional-dependencies",level:3},{value:"TypeScript configuration",id:"typescript-configuration",level:3}],c={toc:s};function d(e){let{components:t,...n}=e;return(0,r.kt)("wrapper",(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("admonition",{type:"info"},(0,r.kt)("p",{parentName:"admonition"},"Be aware that due to usage of some ES2019 and newer Node.js features, you also have to use ",(0,r.kt)("strong",{parentName:"p"},"Node.js v12.4.0 or newer"),".")),(0,r.kt)("h3",{id:"typegraphql"},"TypeGraphQL"),(0,r.kt)("p",null,"First of all, you should perform all the steps described in the TypeGraphQL installation instruction:"),(0,r.kt)("p",null,(0,r.kt)("a",{parentName:"p",href:"https://typegraphql.com/docs/installation.html"},"https://typegraphql.com/docs/installation.html")),(0,r.kt)("h3",{id:"typegraphql-prisma-generator"},(0,r.kt)("inlineCode",{parentName:"h3"},"typegraphql-prisma")," generator"),(0,r.kt)("p",null,"After that, you have to install the generator, as a dev dependency:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"npm i -D typegraphql-prisma\n")),(0,r.kt)("p",null,"Furthermore, ",(0,r.kt)("inlineCode",{parentName:"p"},"typegraphql-prisma")," requires Prisma to work properly, so please install Prisma dependencies if you don't have it already installed:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"npm i -D prisma\nnpm i @prisma/client\n")),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"Be aware that ",(0,r.kt)("inlineCode",{parentName:"p"},"typegraphql-prisma")," is designed to work with a selected versions of ",(0,r.kt)("inlineCode",{parentName:"p"},"prisma"),"."),(0,r.kt)("p",{parentName:"admonition"},"Please make sure you use ",(0,r.kt)("inlineCode",{parentName:"p"},"prisma")," and ",(0,r.kt)("inlineCode",{parentName:"p"},"@prisma/client")," of version matching ",(0,r.kt)("inlineCode",{parentName:"p"},"^4.15.0"),".\nOtherwise, the runtime check will report an error when you run the generator.")),(0,r.kt)("h3",{id:"additional-dependencies"},"Additional dependencies"),(0,r.kt)("p",null,"You also need to install the GraphQL Scalars library (to support the Prisma ",(0,r.kt)("inlineCode",{parentName:"p"},"Json"),", ",(0,r.kt)("inlineCode",{parentName:"p"},"BigInt")," and ",(0,r.kt)("inlineCode",{parentName:"p"},"Byte")," types):"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"npm i graphql-scalars\n")),(0,r.kt)("p",null,"In order to properly support the aggregate and group by queries, the ",(0,r.kt)("inlineCode",{parentName:"p"},"graphql-fields")," package is used, so it also has to be installed:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"npm i graphql-fields @types/graphql-fields\n")),(0,r.kt)("p",null,"Finally, please also install the ",(0,r.kt)("inlineCode",{parentName:"p"},"tslib")," package, which is required for ",(0,r.kt)("a",{parentName:"p",href:"/docs/advanced/additional-decorators"},"applying the additional decorators")," properly:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sh"},"npm i tslib\n")),(0,r.kt)("h3",{id:"typescript-configuration"},"TypeScript configuration"),(0,r.kt)("p",null,"As prisma emits multiple files, make sure you have your tsconfig set properly to ",(0,r.kt)("inlineCode",{parentName:"p"},'"module": "commonjs"'),":"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-json",metastring:"{4}","{4}":!0},'{\n "compilerOptions": {\n "target": "es2018",\n "module": "commonjs",\n "lib": ["es2018", "esnext.asynciterable"],\n "experimentalDecorators": true,\n "emitDecoratorMetadata": true\n }\n}\n')),(0,r.kt)("p",null,"Otherwise you may experience runtime errors like ",(0,r.kt)("inlineCode",{parentName:"p"},"ReferenceError: Cannot access 'BankAccountWhereInput' before initialization"),".\nIt's because those generated files rely on each other, so ",(0,r.kt)("inlineCode",{parentName:"p"},"commonjs")," is needed to handle that cyclic imports."))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/935f2afb.797c9d79.js b/assets/js/935f2afb.156e9628.js similarity index 90% rename from assets/js/935f2afb.797c9d79.js rename to assets/js/935f2afb.156e9628.js index 20313156..442fc27e 100644 --- a/assets/js/935f2afb.797c9d79.js +++ b/assets/js/935f2afb.156e9628.js @@ -1 +1 @@ -"use strict";(self.webpackChunktypegraphql_prisma_website=self.webpackChunktypegraphql_prisma_website||[]).push([[53],{1109:e=>{e.exports=JSON.parse('{"pluginId":"default","version":"current","label":"Next","banner":null,"badge":false,"noIndex":false,"className":"docs-version-current","isLast":true,"docsSidebars":{"docs":[{"type":"link","label":"Introduction","href":"/docs/intro","docId":"intro"},{"type":"category","label":"Basics","items":[{"type":"link","label":"Installation","href":"/docs/basics/installation","docId":"basics/installation"},{"type":"link","label":"Configuration","href":"/docs/basics/configuration","docId":"basics/configuration"},{"type":"link","label":"Usage","href":"/docs/basics/usage","docId":"basics/usage"},{"type":"link","label":"Prisma version check","href":"/docs/basics/prisma-version","docId":"basics/prisma-version"},{"type":"link","label":"Nest JS","href":"/docs/basics/nest-js","docId":"basics/nest-js"}],"collapsed":true,"collapsible":true,"href":"/docs/category/basics"},{"type":"category","label":"Advanced","items":[{"type":"link","label":"Exposing selected models","href":"/docs/advanced/exposing-models","docId":"advanced/exposing-models"},{"type":"link","label":"Exposing selected actions","href":"/docs/advanced/exposing-actions","docId":"advanced/exposing-actions"},{"type":"link","label":"Hiding model fields","href":"/docs/advanced/hiding-field","docId":"advanced/hiding-field"},{"type":"link","label":"Adding model fields","href":"/docs/advanced/adding-fields","docId":"advanced/adding-fields"},{"type":"link","label":"Custom operations","href":"/docs/advanced/custom-operations","docId":"advanced/custom-operations"},{"type":"link","label":"Emit selected blocks","href":"/docs/advanced/emit-blocks","docId":"advanced/emit-blocks"},{"type":"link","label":"Applying decorators","href":"/docs/advanced/additional-decorators","docId":"advanced/additional-decorators"},{"type":"link","label":"Simple inputs","href":"/docs/advanced/simple-inputs","docId":"advanced/simple-inputs"},{"type":"link","label":"Renaming model","href":"/docs/advanced/renaming-model","docId":"advanced/renaming-model"},{"type":"link","label":"Renaming field","href":"/docs/advanced/renaming-field","docId":"advanced/renaming-field"},{"type":"link","label":"Unchecked scalars input","href":"/docs/advanced/unchecked-scalars","docId":"advanced/unchecked-scalars"},{"type":"link","label":"Simple resolvers","href":"/docs/advanced/simple-resolvers","docId":"advanced/simple-resolvers"},{"type":"link","label":"Emit ID type","href":"/docs/advanced/emit-id-type","docId":"advanced/emit-id-type"},{"type":"link","label":"Custom plural form","href":"/docs/advanced/override-plural","docId":"advanced/override-plural"},{"type":"link","label":"Prisma import path","href":"/docs/advanced/custom-prisma-import","docId":"advanced/custom-prisma-import"},{"type":"link","label":"Prisma context key","href":"/docs/advanced/custom-prisma-context-key","docId":"advanced/custom-prisma-context-key"},{"type":"link","label":"Redundant types","href":"/docs/advanced/emit-redundant-types-info","docId":"advanced/emit-redundant-types-info"},{"type":"link","label":"Overriding object decorator","href":"/docs/advanced/overriding-object-decorator","docId":"advanced/overriding-object-decorator"},{"type":"link","label":"Emit isAbstract","href":"/docs/advanced/emit-is-abstract","docId":"advanced/emit-is-abstract"}],"collapsed":true,"collapsible":true,"href":"/docs/category/advanced"}],"examples":[{"type":"link","label":"Examples","href":"/docs/examples","docId":"examples"}]},"docs":{"advanced/adding-fields":{"id":"advanced/adding-fields","title":"Adding fields to model type","description":"If you want to add a field to the generated type like User, you have to create a proper @FieldResolver for that:","sidebar":"docs"},"advanced/additional-decorators":{"id":"advanced/additional-decorators","title":"Additional decorators for CRUD resolvers and Prisma classes and fields","description":"Additional decorators for Prisma schema resolvers","sidebar":"docs"},"advanced/custom-operations":{"id":"advanced/custom-operations","title":"Custom operations","description":"You can also add custom queries and mutations to the schema as always, using the generated PrismaClient:","sidebar":"docs"},"advanced/custom-prisma-context-key":{"id":"advanced/custom-prisma-context-key","title":"Custom Prisma Client context key","description":"By default, typegraphql-prisma looks in runtime for Prisma Client in the GraphQL context under the prisma key.","sidebar":"docs"},"advanced/custom-prisma-import":{"id":"advanced/custom-prisma-import","title":"Custom Prisma Client import path","description":"If you have a complex repository structure, e.g. with multiple Prisma clients generated, you can provide a custom Prisma import path as a generator option:","sidebar":"docs"},"advanced/emit-blocks":{"id":"advanced/emit-blocks","title":"Emit only selected blocks","description":"If you don\'t want to have generated all the CRUD API with all resolvers, arguments, inputs, outputs, models, etc., you can provide an emitOnly generator option, which accepts an array of values","sidebar":"docs"},"advanced/emit-id-type":{"id":"advanced/emit-id-type","title":"Emit ID fields with type","description":"By default, TypeGraphQL Prisma generator emits GraphQL types for fields with the underlying data types, like Int or String scalars.","sidebar":"docs"},"advanced/emit-is-abstract":{"id":"advanced/emit-is-abstract","title":"Emit `isAbstract` decorator option","description":"By default, TypeGraphQL Prisma generator aims to work with newest release of TypeGraphQL.","sidebar":"docs"},"advanced/emit-redundant-types-info":{"id":"advanced/emit-redundant-types-info","title":"Emit redundant types info","description":"By default, typegraphql-prisma tries to minimize the generated LOC by omitting the redundant types info.","sidebar":"docs"},"advanced/exposing-actions":{"id":"advanced/exposing-actions","title":"Exposing selected Prisma actions only","description":"If you want to expose only certain Prisma actions, like findManyUser or createOneUser, you can import resolver classes only for them, instead of the whole model XYZCrudResolver.","sidebar":"docs"},"advanced/exposing-models":{"id":"advanced/exposing-models","title":"Exposing selected models Prisma CRUD actions","description":"If you want to expose only CRUD Prisma actions for selected models, you can import crud resolver classes only for that models, instead of the all-in-one resolvers object.","sidebar":"docs"},"advanced/hiding-field":{"id":"advanced/hiding-field","title":"Hiding Prisma model field in GraphQL schema","description":"Hiding field in output types","sidebar":"docs"},"advanced/override-plural":{"id":"advanced/override-plural","title":"Overriding plural form of model name","description":"In some cases, the noun used as the model name might not have a proper plural form. For example, the word \\"fish\\" is not pluralized to \\"fishes\\". In such cases, you can override the plural form by adding a plural argument to the @@TypeGraphQL.type comment attribute, e.g.:","sidebar":"docs"},"advanced/overriding-object-decorator":{"id":"advanced/overriding-object-decorator","title":"Overriding generated @ObjectType decorator for model","description":"By default, typegraphql-prisma generator emits TypeGraphQL classes for models with all the decorators applied.","sidebar":"docs"},"advanced/renaming-field":{"id":"advanced/renaming-field","title":"Changing exposed model type field name","description":"You can also change the name of the model type fields exposed in GraphQL Schema.","sidebar":"docs"},"advanced/renaming-model":{"id":"advanced/renaming-model","title":"Changing exposed model type name","description":"You can also change the name of the model types exposed in GraphQL Schema.","sidebar":"docs"},"advanced/simple-inputs":{"id":"advanced/simple-inputs","title":"Simple and flat inputs","description":"In version 2.6.0, Prisma released atomicNumberOperations preview feature that allows you to update scalar fields without checking the current value, e.g. increment or decrement a number value.","sidebar":"docs"},"advanced/simple-resolvers":{"id":"advanced/simple-resolvers","title":"Simple resolvers (performance)","description":"If you don\'t have any global middlewares and you want to tune the generated schema performance, you can turn on the simpleResolvers generator option:","sidebar":"docs"},"advanced/unchecked-scalars":{"id":"advanced/unchecked-scalars","title":"Unchecked scalars input","description":"GraphQL does not support input unions, hence it\'s not possible to support both normal inputs and unchecked scalars input at the same time like the Prisma does.","sidebar":"docs"},"basics/configuration":{"id":"basics/configuration","title":"Configuration","description":"Creating generator block","sidebar":"docs"},"basics/installation":{"id":"basics/installation","title":"Installation","description":"Be aware that due to usage of some ES2019 and newer Node.js features, you also have to use Node.js v12.4.0 or newer.","sidebar":"docs"},"basics/nest-js":{"id":"basics/nest-js","title":"Nest JS","description":"typegraphql-nestjs","sidebar":"docs"},"basics/prisma-version":{"id":"basics/prisma-version","title":"Prisma version verification","description":"Checking installed Prisma version","sidebar":"docs"},"basics/usage":{"id":"basics/usage","title":"Usage","description":"Having installed all the deps and configured the Prisma generator, let\'s see the capabilities of typegraphql-prisma.","sidebar":"docs"},"examples":{"id":"examples","title":"Examples","description":"In the GitHub repository you can find a few examples of using the TypeGraphQL Prisma integration:"},"intro":{"id":"intro","title":"Introduction","description":"Let\'s discover TypeGraphQL Prisma in less than 3 minutes.","sidebar":"docs"}}}')}}]); \ No newline at end of file +"use strict";(self.webpackChunktypegraphql_prisma_website=self.webpackChunktypegraphql_prisma_website||[]).push([[53],{1109:e=>{e.exports=JSON.parse('{"pluginId":"default","version":"current","label":"Next","banner":null,"badge":false,"noIndex":false,"className":"docs-version-current","isLast":true,"docsSidebars":{"docs":[{"type":"link","label":"Introduction","href":"/docs/intro","docId":"intro"},{"type":"category","label":"Basics","items":[{"type":"link","label":"Installation","href":"/docs/basics/installation","docId":"basics/installation"},{"type":"link","label":"Configuration","href":"/docs/basics/configuration","docId":"basics/configuration"},{"type":"link","label":"Usage","href":"/docs/basics/usage","docId":"basics/usage"},{"type":"link","label":"Prisma version check","href":"/docs/basics/prisma-version","docId":"basics/prisma-version"},{"type":"link","label":"Nest JS","href":"/docs/basics/nest-js","docId":"basics/nest-js"}],"collapsed":true,"collapsible":true,"href":"/docs/category/basics"},{"type":"category","label":"Advanced","items":[{"type":"link","label":"Exposing selected models","href":"/docs/advanced/exposing-models","docId":"advanced/exposing-models"},{"type":"link","label":"Exposing selected actions","href":"/docs/advanced/exposing-actions","docId":"advanced/exposing-actions"},{"type":"link","label":"Hiding model fields","href":"/docs/advanced/hiding-field","docId":"advanced/hiding-field"},{"type":"link","label":"Adding model fields","href":"/docs/advanced/adding-fields","docId":"advanced/adding-fields"},{"type":"link","label":"Custom operations","href":"/docs/advanced/custom-operations","docId":"advanced/custom-operations"},{"type":"link","label":"Emit selected blocks","href":"/docs/advanced/emit-blocks","docId":"advanced/emit-blocks"},{"type":"link","label":"Applying decorators","href":"/docs/advanced/additional-decorators","docId":"advanced/additional-decorators"},{"type":"link","label":"Simple inputs","href":"/docs/advanced/simple-inputs","docId":"advanced/simple-inputs"},{"type":"link","label":"Renaming model","href":"/docs/advanced/renaming-model","docId":"advanced/renaming-model"},{"type":"link","label":"Renaming field","href":"/docs/advanced/renaming-field","docId":"advanced/renaming-field"},{"type":"link","label":"Unchecked scalars input","href":"/docs/advanced/unchecked-scalars","docId":"advanced/unchecked-scalars"},{"type":"link","label":"Simple resolvers","href":"/docs/advanced/simple-resolvers","docId":"advanced/simple-resolvers"},{"type":"link","label":"Emit ID type","href":"/docs/advanced/emit-id-type","docId":"advanced/emit-id-type"},{"type":"link","label":"Custom plural form","href":"/docs/advanced/override-plural","docId":"advanced/override-plural"},{"type":"link","label":"Prisma import path","href":"/docs/advanced/custom-prisma-import","docId":"advanced/custom-prisma-import"},{"type":"link","label":"Prisma context key","href":"/docs/advanced/custom-prisma-context-key","docId":"advanced/custom-prisma-context-key"},{"type":"link","label":"Redundant types","href":"/docs/advanced/emit-redundant-types-info","docId":"advanced/emit-redundant-types-info"},{"type":"link","label":"Overriding object decorator","href":"/docs/advanced/overriding-object-decorator","docId":"advanced/overriding-object-decorator"},{"type":"link","label":"Emit isAbstract","href":"/docs/advanced/emit-is-abstract","docId":"advanced/emit-is-abstract"}],"collapsed":true,"collapsible":true,"href":"/docs/category/advanced"}],"examples":[{"type":"link","label":"Examples","href":"/docs/examples","docId":"examples"}]},"docs":{"advanced/adding-fields":{"id":"advanced/adding-fields","title":"Adding fields to model type","description":"If you want to add a field to the generated type like User, you have to create a proper @FieldResolver for that:","sidebar":"docs"},"advanced/additional-decorators":{"id":"advanced/additional-decorators","title":"Additional decorators for CRUD resolvers and Prisma classes and fields","description":"Additional decorators for Prisma schema resolvers","sidebar":"docs"},"advanced/custom-operations":{"id":"advanced/custom-operations","title":"Custom operations","description":"You can also add custom queries and mutations to the schema as always, using the generated PrismaClient:","sidebar":"docs"},"advanced/custom-prisma-context-key":{"id":"advanced/custom-prisma-context-key","title":"Custom Prisma Client context key","description":"By default, typegraphql-prisma looks in runtime for Prisma Client in the GraphQL context under the prisma key.","sidebar":"docs"},"advanced/custom-prisma-import":{"id":"advanced/custom-prisma-import","title":"Custom Prisma Client import path","description":"If you have a complex repository structure, e.g. with multiple Prisma clients generated, you can provide a custom Prisma import path as a generator option:","sidebar":"docs"},"advanced/emit-blocks":{"id":"advanced/emit-blocks","title":"Emit only selected blocks","description":"If you don\'t want to have generated all the CRUD API with all resolvers, arguments, inputs, outputs, models, etc., you can provide an emitOnly generator option, which accepts an array of values","sidebar":"docs"},"advanced/emit-id-type":{"id":"advanced/emit-id-type","title":"Emit ID fields with type","description":"By default, TypeGraphQL Prisma generator emits GraphQL types for fields with the underlying data types, like Int or String scalars.","sidebar":"docs"},"advanced/emit-is-abstract":{"id":"advanced/emit-is-abstract","title":"Emit `isAbstract` decorator option","description":"By default, TypeGraphQL Prisma generator aims to work with newest release of TypeGraphQL.","sidebar":"docs"},"advanced/emit-redundant-types-info":{"id":"advanced/emit-redundant-types-info","title":"Emit redundant types info","description":"By default, typegraphql-prisma tries to minimize the generated LOC by omitting the redundant types info.","sidebar":"docs"},"advanced/exposing-actions":{"id":"advanced/exposing-actions","title":"Exposing selected Prisma actions only","description":"If you want to expose only certain Prisma actions, like findManyUser or createOneUser, you can import resolver classes only for them, instead of the whole model XYZCrudResolver.","sidebar":"docs"},"advanced/exposing-models":{"id":"advanced/exposing-models","title":"Exposing selected models Prisma CRUD actions","description":"If you want to expose only CRUD Prisma actions for selected models, you can import crud resolver classes only for that models, instead of the all-in-one resolvers object.","sidebar":"docs"},"advanced/hiding-field":{"id":"advanced/hiding-field","title":"Hiding Prisma model field in GraphQL schema","description":"Hiding field in output types","sidebar":"docs"},"advanced/override-plural":{"id":"advanced/override-plural","title":"Overriding plural form of model name","description":"In some cases, the noun used as the model name might not have a proper plural form. For example, the word \\"fish\\" is not pluralized to \\"fishes\\". In such cases, you can override the plural form by adding a plural argument to the @@TypeGraphQL.type comment attribute, e.g.:","sidebar":"docs"},"advanced/overriding-object-decorator":{"id":"advanced/overriding-object-decorator","title":"Overriding generated @ObjectType decorator for model","description":"By default, typegraphql-prisma generator emits TypeGraphQL classes for models with all the decorators applied.","sidebar":"docs"},"advanced/renaming-field":{"id":"advanced/renaming-field","title":"Changing exposed model type field name","description":"You can also change the name of the model type fields exposed in GraphQL Schema.","sidebar":"docs"},"advanced/renaming-model":{"id":"advanced/renaming-model","title":"Changing exposed model type name","description":"You can also change the name of the model types exposed in GraphQL Schema.","sidebar":"docs"},"advanced/simple-inputs":{"id":"advanced/simple-inputs","title":"Simple and flat inputs","description":"In version 2.6.0, Prisma released atomicNumberOperations preview feature that allows you to update scalar fields without checking the current value, e.g. increment or decrement a number value.","sidebar":"docs"},"advanced/simple-resolvers":{"id":"advanced/simple-resolvers","title":"Simple resolvers (performance)","description":"If you don\'t have any global middlewares and you want to tune the generated schema performance, you can turn on the simpleResolvers generator option:","sidebar":"docs"},"advanced/unchecked-scalars":{"id":"advanced/unchecked-scalars","title":"Unchecked scalars input","description":"GraphQL does not support input unions, hence it\'s not possible to support both normal inputs and unchecked scalars input at the same time like the Prisma does.","sidebar":"docs"},"basics/configuration":{"id":"basics/configuration","title":"Configuration","description":"Creating generator block","sidebar":"docs"},"basics/installation":{"id":"basics/installation","title":"Installation","description":"Be aware that due to usage of some ES2022 and newer Node.js features, you also have to use Node.js v16.13.0 or newer.","sidebar":"docs"},"basics/nest-js":{"id":"basics/nest-js","title":"Nest JS","description":"typegraphql-nestjs","sidebar":"docs"},"basics/prisma-version":{"id":"basics/prisma-version","title":"Prisma version verification","description":"Checking installed Prisma version","sidebar":"docs"},"basics/usage":{"id":"basics/usage","title":"Usage","description":"Having installed all the deps and configured the Prisma generator, let\'s see the capabilities of typegraphql-prisma.","sidebar":"docs"},"examples":{"id":"examples","title":"Examples","description":"In the GitHub repository you can find a few examples of using the TypeGraphQL Prisma integration:"},"intro":{"id":"intro","title":"Introduction","description":"Let\'s discover TypeGraphQL Prisma in less than 3 minutes.","sidebar":"docs"}}}')}}]); \ No newline at end of file diff --git a/assets/js/runtime~main.a571bf35.js b/assets/js/runtime~main.dd4d087e.js similarity index 97% rename from assets/js/runtime~main.a571bf35.js rename to assets/js/runtime~main.dd4d087e.js index e55002c2..9acf7b81 100644 --- a/assets/js/runtime~main.a571bf35.js +++ b/assets/js/runtime~main.dd4d087e.js @@ -1 +1 @@ -(()=>{"use strict";var e,t,a,r,c,f={},o={};function d(e){var t=o[e];if(void 0!==t)return t.exports;var a=o[e]={id:e,loaded:!1,exports:{}};return f[e].call(a.exports,a,a.exports,d),a.loaded=!0,a.exports}d.m=f,d.c=o,e=[],d.O=(t,a,r,c)=>{if(!a){var f=1/0;for(i=0;i=c)&&Object.keys(d.O).every((e=>d.O[e](a[b])))?a.splice(b--,1):(o=!1,c0&&e[i-1][2]>c;i--)e[i]=e[i-1];e[i]=[a,r,c]},d.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return d.d(t,{a:t}),t},a=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,d.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var c=Object.create(null);d.r(c);var f={};t=t||[null,a({}),a([]),a(a)];for(var o=2&r&&e;"object"==typeof o&&!~t.indexOf(o);o=a(o))Object.getOwnPropertyNames(o).forEach((t=>f[t]=()=>e[t]));return f.default=()=>e,d.d(c,f),c},d.d=(e,t)=>{for(var a in t)d.o(t,a)&&!d.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},d.f={},d.e=e=>Promise.all(Object.keys(d.f).reduce(((t,a)=>(d.f[a](e,t),t)),[])),d.u=e=>"assets/js/"+({18:"e102aa50",53:"935f2afb",63:"a6c5a0ba",68:"111a627b",86:"8758cede",91:"afc50c8b",132:"1ec2ab79",147:"1a536a70",168:"7a696186",198:"c55f8638",202:"21cf64c5",223:"7bc42550",237:"1df93b7f",242:"1daf622d",283:"87ce6598",295:"28946bcb",367:"f44f9c38",370:"332c17cc",418:"6945c6f3",444:"55fc5a37",463:"f6d69ff8",510:"d665a578",514:"1be78505",521:"16452c0b",561:"9c24ad64",566:"9cc12e19",666:"c9ea91f4",765:"d9dd309c",766:"1b0b9296",816:"e9e18205",817:"14eb3368",882:"fbd83eba",908:"ef0beff2",913:"04c861e4",918:"17896441",920:"1a4e3797",991:"c3fbe093"}[e]||e)+"."+{18:"95bfa25a",53:"797c9d79",63:"750e5de2",68:"df0d635c",86:"889cd178",91:"5ce71374",132:"b386def5",147:"6c8fac21",168:"c25f2ff6",198:"b007d44c",202:"a78b3d95",223:"1ea97cfd",237:"a315f5b4",242:"2f844747",283:"887522bb",295:"cb2eb231",367:"ac2023ee",370:"c79706bf",418:"51e2d712",444:"82d9a52a",463:"0334962d",510:"ee079e2e",514:"6b986d9a",521:"31915319",561:"be4610f4",566:"f886d8f1",666:"9bbb45a8",765:"75035378",766:"72131ddb",780:"257c7eb5",816:"19fa8d1e",817:"ceb3f6aa",882:"87a5eb70",894:"ce4ba6b3",908:"bfcfa0aa",913:"94fcd6e3",918:"5b9c0887",920:"d613a5b6",945:"b89f91f4",972:"0e3aed5b",991:"6792d90d"}[e]+".js",d.miniCssF=e=>{},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},c="typegraphql-prisma-website:",d.l=(e,t,a,f)=>{if(r[e])r[e].push(t);else{var o,b;if(void 0!==a)for(var n=document.getElementsByTagName("script"),i=0;i{o.onerror=o.onload=null,clearTimeout(s);var c=r[e];if(delete r[e],o.parentNode&&o.parentNode.removeChild(o),c&&c.forEach((e=>e(a))),t)return t(a)},s=setTimeout(u.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=u.bind(null,o.onerror),o.onload=u.bind(null,o.onload),b&&document.head.appendChild(o)}},d.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.p="/",d.gca=function(e){return e={17896441:"918",e102aa50:"18","935f2afb":"53",a6c5a0ba:"63","111a627b":"68","8758cede":"86",afc50c8b:"91","1ec2ab79":"132","1a536a70":"147","7a696186":"168",c55f8638:"198","21cf64c5":"202","7bc42550":"223","1df93b7f":"237","1daf622d":"242","87ce6598":"283","28946bcb":"295",f44f9c38:"367","332c17cc":"370","6945c6f3":"418","55fc5a37":"444",f6d69ff8:"463",d665a578:"510","1be78505":"514","16452c0b":"521","9c24ad64":"561","9cc12e19":"566",c9ea91f4:"666",d9dd309c:"765","1b0b9296":"766",e9e18205:"816","14eb3368":"817",fbd83eba:"882",ef0beff2:"908","04c861e4":"913","1a4e3797":"920",c3fbe093:"991"}[e]||e,d.p+d.u(e)},(()=>{var e={303:0,532:0};d.f.j=(t,a)=>{var r=d.o(e,t)?e[t]:void 0;if(0!==r)if(r)a.push(r[2]);else if(/^(303|532)$/.test(t))e[t]=0;else{var c=new Promise(((a,c)=>r=e[t]=[a,c]));a.push(r[2]=c);var f=d.p+d.u(t),o=new Error;d.l(f,(a=>{if(d.o(e,t)&&(0!==(r=e[t])&&(e[t]=void 0),r)){var c=a&&("load"===a.type?"missing":a.type),f=a&&a.target&&a.target.src;o.message="Loading chunk "+t+" failed.\n("+c+": "+f+")",o.name="ChunkLoadError",o.type=c,o.request=f,r[1](o)}}),"chunk-"+t,t)}},d.O.j=t=>0===e[t];var t=(t,a)=>{var r,c,f=a[0],o=a[1],b=a[2],n=0;if(f.some((t=>0!==e[t]))){for(r in o)d.o(o,r)&&(d.m[r]=o[r]);if(b)var i=b(d)}for(t&&t(a);n{"use strict";var e,t,a,r,c,f={},o={};function d(e){var t=o[e];if(void 0!==t)return t.exports;var a=o[e]={id:e,loaded:!1,exports:{}};return f[e].call(a.exports,a,a.exports,d),a.loaded=!0,a.exports}d.m=f,d.c=o,e=[],d.O=(t,a,r,c)=>{if(!a){var f=1/0;for(i=0;i=c)&&Object.keys(d.O).every((e=>d.O[e](a[b])))?a.splice(b--,1):(o=!1,c0&&e[i-1][2]>c;i--)e[i]=e[i-1];e[i]=[a,r,c]},d.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return d.d(t,{a:t}),t},a=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,d.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var c=Object.create(null);d.r(c);var f={};t=t||[null,a({}),a([]),a(a)];for(var o=2&r&&e;"object"==typeof o&&!~t.indexOf(o);o=a(o))Object.getOwnPropertyNames(o).forEach((t=>f[t]=()=>e[t]));return f.default=()=>e,d.d(c,f),c},d.d=(e,t)=>{for(var a in t)d.o(t,a)&&!d.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},d.f={},d.e=e=>Promise.all(Object.keys(d.f).reduce(((t,a)=>(d.f[a](e,t),t)),[])),d.u=e=>"assets/js/"+({18:"e102aa50",53:"935f2afb",63:"a6c5a0ba",68:"111a627b",86:"8758cede",91:"afc50c8b",132:"1ec2ab79",147:"1a536a70",168:"7a696186",198:"c55f8638",202:"21cf64c5",223:"7bc42550",237:"1df93b7f",242:"1daf622d",283:"87ce6598",295:"28946bcb",367:"f44f9c38",370:"332c17cc",418:"6945c6f3",444:"55fc5a37",463:"f6d69ff8",510:"d665a578",514:"1be78505",521:"16452c0b",561:"9c24ad64",566:"9cc12e19",666:"c9ea91f4",765:"d9dd309c",766:"1b0b9296",816:"e9e18205",817:"14eb3368",882:"fbd83eba",908:"ef0beff2",913:"04c861e4",918:"17896441",920:"1a4e3797",991:"c3fbe093"}[e]||e)+"."+{18:"95bfa25a",53:"156e9628",63:"750e5de2",68:"df0d635c",86:"889cd178",91:"5ce71374",132:"b386def5",147:"6c8fac21",168:"c25f2ff6",198:"b007d44c",202:"a78b3d95",223:"1ea97cfd",237:"a315f5b4",242:"2f844747",283:"887522bb",295:"cb2eb231",367:"ac2023ee",370:"0b5eb393",418:"51e2d712",444:"82d9a52a",463:"0334962d",510:"ee079e2e",514:"6b986d9a",521:"31915319",561:"be4610f4",566:"f886d8f1",666:"9bbb45a8",765:"75035378",766:"72131ddb",780:"257c7eb5",816:"19fa8d1e",817:"ceb3f6aa",882:"87a5eb70",894:"ce4ba6b3",908:"bfcfa0aa",913:"94fcd6e3",918:"5b9c0887",920:"d613a5b6",945:"b89f91f4",972:"0e3aed5b",991:"6792d90d"}[e]+".js",d.miniCssF=e=>{},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r={},c="typegraphql-prisma-website:",d.l=(e,t,a,f)=>{if(r[e])r[e].push(t);else{var o,b;if(void 0!==a)for(var n=document.getElementsByTagName("script"),i=0;i{o.onerror=o.onload=null,clearTimeout(s);var c=r[e];if(delete r[e],o.parentNode&&o.parentNode.removeChild(o),c&&c.forEach((e=>e(a))),t)return t(a)},s=setTimeout(u.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=u.bind(null,o.onerror),o.onload=u.bind(null,o.onload),b&&document.head.appendChild(o)}},d.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.p="/",d.gca=function(e){return e={17896441:"918",e102aa50:"18","935f2afb":"53",a6c5a0ba:"63","111a627b":"68","8758cede":"86",afc50c8b:"91","1ec2ab79":"132","1a536a70":"147","7a696186":"168",c55f8638:"198","21cf64c5":"202","7bc42550":"223","1df93b7f":"237","1daf622d":"242","87ce6598":"283","28946bcb":"295",f44f9c38:"367","332c17cc":"370","6945c6f3":"418","55fc5a37":"444",f6d69ff8:"463",d665a578:"510","1be78505":"514","16452c0b":"521","9c24ad64":"561","9cc12e19":"566",c9ea91f4:"666",d9dd309c:"765","1b0b9296":"766",e9e18205:"816","14eb3368":"817",fbd83eba:"882",ef0beff2:"908","04c861e4":"913","1a4e3797":"920",c3fbe093:"991"}[e]||e,d.p+d.u(e)},(()=>{var e={303:0,532:0};d.f.j=(t,a)=>{var r=d.o(e,t)?e[t]:void 0;if(0!==r)if(r)a.push(r[2]);else if(/^(303|532)$/.test(t))e[t]=0;else{var c=new Promise(((a,c)=>r=e[t]=[a,c]));a.push(r[2]=c);var f=d.p+d.u(t),o=new Error;d.l(f,(a=>{if(d.o(e,t)&&(0!==(r=e[t])&&(e[t]=void 0),r)){var c=a&&("load"===a.type?"missing":a.type),f=a&&a.target&&a.target.src;o.message="Loading chunk "+t+" failed.\n("+c+": "+f+")",o.name="ChunkLoadError",o.type=c,o.request=f,r[1](o)}}),"chunk-"+t,t)}},d.O.j=t=>0===e[t];var t=(t,a)=>{var r,c,f=a[0],o=a[1],b=a[2],n=0;if(f.some((t=>0!==e[t]))){for(r in o)d.o(o,r)&&(d.m[r]=o[r]);if(b)var i=b(d)}for(t&&t(a);n Adding fields to model type | TypeGraphQL Prisma - +

Adding fields to model type

If you want to add a field to the generated type like User, you have to create a proper @FieldResolver for that:

@Resolver(of => User)
export class CustomUserResolver {
@FieldResolver(type => Post, { nullable: true })
async favoritePost(
@Root() user: User,
@Ctx() { prisma }: Context,
): Promise<Post | undefined> {
const [favoritePost] = await prisma.user
.findUniqueOrThrow({ where: { id: user.id } })
.posts({ first: 1 });

return favoritePost;
}
}
- + \ No newline at end of file diff --git a/docs/advanced/additional-decorators/index.html b/docs/advanced/additional-decorators/index.html index 11bc9e4c..3554db27 100644 --- a/docs/advanced/additional-decorators/index.html +++ b/docs/advanced/additional-decorators/index.html @@ -4,7 +4,7 @@ Additional decorators for CRUD resolvers and Prisma classes and fields | TypeGraphQL Prisma - + @@ -12,7 +12,7 @@

Additional decorators for CRUD resolvers and Prisma classes and fields

Additional decorators for Prisma schema resolvers

When you need to apply some decorators like @Authorized, @UseMiddleware or @Extensions on the generated resolvers methods, you don't need to modify the generated source files.

To support this, typegraphql-prisma generates two things: applyResolversEnhanceMap function and a ResolversEnhanceMap type. All you need to do is to create a config object, where you put the decorator functions (without @) in an array, and then call that function with that config, eg.:

import {
ResolversEnhanceMap,
applyResolversEnhanceMap,
} from "@generated/type-graphql";
import { Authorized } from "type-graphql";

const resolversEnhanceMap: ResolversEnhanceMap = {
Category: {
createCategory: [Authorized(Role.ADMIN)],
},
};

applyResolversEnhanceMap(resolversEnhanceMap);

This way, when you call createCategory GraphQL mutation, it will trigger the type-graphql authChecker function, providing a Role.ADMIN role, just like you would put the @Authorized on top of the resolver method.

Also, if you have a large schema and you need to provide plenty of decorators, you can split the config definition into multiple smaller objects placed in different files. To accomplish this, just import the generic ResolverActionsConfig type and define the resolvers config separately for every Prisma schema model, e.g:

import {
ResolversEnhanceMap,
ResolverActionsConfig,
applyResolversEnhanceMap,
} from "@generated/type-graphql";
import { Authorized, Extensions } from "type-graphql";

// define the decorators config using generic ResolverActionsConfig<TModelName> type
const categoryActionsConfig: ResolverActionsConfig<"Category"> = {
deleteCategory: [
Authorized(Role.ADMIN),
Extensions({ logMessage: "Danger zone", logLevel: LogLevel.WARN }),
],
};
const problemActionsConfig: ResolverActionsConfig<"Problem"> = {
createProblem: [Authorized()],
};

// join the actions config into a single resolvers enhance object
const resolversEnhanceMap: ResolversEnhanceMap = {
Category: categoryActionsConfig,
Problem: problemActionsConfig,
};

// apply the config (it will apply decorators on the resolver class methods)
applyResolversEnhanceMap(resolversEnhanceMap);

If you want to apply some decorators on all the methods of a model CRUD resolver, you can use the special _all property to achieve that:

applyResolversEnhanceMap({
Client: {
_all: [Authorized()],
},
});

However, be aware that this will apply the decorators on all the methods of the resolver. The decorators will be combined together with the ones provided for selected methods:

applyResolversEnhanceMap({
Client: {
_all: [Authorized()],
deleteClient: [Extensions({ logMessage: "Danger zone" })],
},
});

In some cases, this might not be the desired behavior, e.g. when you define the @Authorized decorator rules on the _all property, but then you want override that and provide different roles for some query or make it a public one.

To accomplish this, you need to use the function variant of the ResolverActionsConfig, which is supposed to return a new array of decorators that will be applied on the selected method:

applyResolversEnhanceMap({
Story: {
_all: [Authorized(Role.ADMIN, Role.MEMBER)],
createStory: () => [Authorized(Role.SUPER_ADMIN)], // require higher role
story: () => [], // make it public
},
});

It also takes the _all decorators as a parameter, so you can leverage that to combine the _all and selected method decorators in a desired way:

applyResolversEnhanceMap({
Client: {
_all: [Extensions({ logMessage: "Fun zone" }), Authorized()],
deleteClient:
// ignore log message extension
([_logExtension, auth]) => [
// provide own message
Extensions({ logMessage: "Danger zone" }),
auth,
],
},
});

You can also use the _query and _mutation shorthands to apply decorators only to the queries or mutations, e.g.:

applyResolversEnhanceMap({
Client: {
_all: [UseMiddleware(LogMiddleware)],
_query: [Authorized()],
_mutation: [Authorized(Role.ADMIN)], // only admin can change the data
},
});

Additional decorators for Prisma schema classes and fields

If you need to apply some decorators, like @Authorized or @Extensions, on the model @ObjectType and its fields, you can use similar pattern as for the resolver actions described above.

All you need to do is to import ModelsEnhanceMap type and applyModelsEnhanceMap function, and then create a config object, where you put the decorator functions (without @) in an array. If you want to split the config definitions, you can use ModelConfig type in the same way like ResolverActionsConfig, e.g.:

import {
ModelsEnhanceMap,
ModelConfig,
applyModelsEnhanceMap,
} from "@generated/type-graphql";
import { Authorized, Extensions } from "type-graphql";

// define the decorators configs
const userEnhanceConfig: ModelConfig<"User"> = {
fields: {
email: [
Authorized(Role.ADMIN),
Extensions({ logMessage: "Danger zone", logLevel: LogLevel.WARN }),
],
},
};
const modelsEnhanceMap: ModelsEnhanceMap = {
User: userEnhanceConfig,
// or apply it inline
Recipe: {
class: [
// decorators for @ObjectType model class
Extensions({ logMessage: "Secret recipe", logLevel: LogLevel.INFO }),
],
fields: {
// decorator for model class fields
averageRating: [Authorized()],
},
},
};

// apply the config (it will apply decorators on the model class and its properties)
applyModelsEnhanceMap(modelsEnhanceMap);

This way, you can apply some rules on single model or its fields, like User.email visible only for Admin.

If you want to apply some decorators on all the fields of a model, you can use the special _all property to achieve that (which also can be overwritten using the function variant, like in the resolver actions config):

applyModelsEnhanceMap({
User: {
fields: {
// all fields are protected against unauthorized access
_all: [Authorized()],
// this field has additional decorators to apply
password: [
Extensions({ logMessage: "Danger zone", logLevel: LogLevel.WARN }),
],
// this field is public, no `@Authorized` decorator returned
id: allDecorators => [],
},
},
});

If you want to apply decorator to model's relation field, you need to use the applyRelationResolversEnhanceMap function and RelationResolverActionsConfig<TModel> type if you need to separate the configs. In order to apply some decorators on all the fields of a model, you can use the special _all property to achieve that, and override that for some specific fields using the function variant:

const clientRelationEnhanceConfig: RelationResolverActionsConfig<"Client"> = {
posts: [
UseMiddleware((_data, next) => {
console.log("Client.posts relation field accessed");
return next();
}),
],
};

applyRelationResolversEnhanceMap({
Client: clientRelationEnhanceConfig,
Product: {
fields: {
// all relation fields are protected against unauthorized access
_all: [Authorized()],
// but designer relation field is public
designer: allDecorators => [],
},
},
});

In case of other output types like AggregateFooBar, you can use the same pattern but this time using the applyOutputTypesEnhanceMap function and OutputTypeConfig or OutputTypesEnhanceMap types:

const aggregateClientConfig: OutputTypeConfig<"AggregateClient"> = {
fields: {
avg: [Extensions({ complexity: 10 })],
},
};

applyOutputTypesEnhanceMap({
// separate config
AggregateClient: aggregateClientConfig,
// or an inline one
ClientAvgAggregate: {
fields: {
_all: [Extensions({ complexity: 10 })],
age: [Authorized()],
},
},
});

If you want to add decorators for input types or args classes, you can leverage applyArgsTypesEnhanceMap and applyInputTypesEnhanceMap functions and use ArgsTypesEnhanceMap, ArgConfig<TArgsType>, InputTypesEnhanceMap, InputTypeConfig<TInput> types if you want to split the definitions. The special _all property also can apply the decorators to all the fields, with the ability to override it using the the function variant for other fields, like in the resolver actions config:

applyArgsTypesEnhanceMap({
CreateProblemArgs: {
fields: {
data: [ValidateNested()],
},
},
});

applyInputTypesEnhanceMap({
ProblemCreateInput: {
fields: {
_all: [Allow()],
problemText: allDecorators => [MinLength(10)],
},
},
});

Be aware that in case of class-validator you need to add @ValidateNested decorator to the args classes to trigger validation of the proper input types.

- + \ No newline at end of file diff --git a/docs/advanced/custom-operations/index.html b/docs/advanced/custom-operations/index.html index 5bf19d3b..004dd0c7 100644 --- a/docs/advanced/custom-operations/index.html +++ b/docs/advanced/custom-operations/index.html @@ -4,13 +4,13 @@ Custom operations | TypeGraphQL Prisma - +

Custom operations

You can also add custom queries and mutations to the schema as always, using the generated PrismaClient:

@Resolver()
export class CustomUserResolver {
@Query(returns => User, { nullable: true })
async bestUser(@Ctx() { prisma }: Context): Promise<User | null> {
return await prisma.user.findUnique({
where: { email: "bob@prisma.io" },
});
}
}
- + \ No newline at end of file diff --git a/docs/advanced/custom-prisma-context-key/index.html b/docs/advanced/custom-prisma-context-key/index.html index d8a2d7b1..9df2590a 100644 --- a/docs/advanced/custom-prisma-context-key/index.html +++ b/docs/advanced/custom-prisma-context-key/index.html @@ -4,13 +4,13 @@ Custom Prisma Client context key | TypeGraphQL Prisma - +

Custom Prisma Client context key

By default, typegraphql-prisma looks in runtime for Prisma Client in the GraphQL context under the prisma key.

However, in some cases like when you have multiple Prisma clients generated, you can provide a generator option to set the custom key for context object, where the Prisma Client can be found:

generator typegraphql {
provider = "typegraphql-prisma"
contextPrismaKey = "customPrisma"
}

By using this option, all the generated resolvers will try to use the Prisma Client from context["customPrisma"] instead of the standard context.prisma.

- + \ No newline at end of file diff --git a/docs/advanced/custom-prisma-import/index.html b/docs/advanced/custom-prisma-import/index.html index 60476e99..971b3748 100644 --- a/docs/advanced/custom-prisma-import/index.html +++ b/docs/advanced/custom-prisma-import/index.html @@ -4,13 +4,13 @@ Custom Prisma Client import path | TypeGraphQL Prisma - +

Custom Prisma Client import path

If you have a complex repository structure, e.g. with multiple Prisma clients generated, you can provide a custom Prisma import path as a generator option:

generator typegraphql {
provider = "typegraphql-prisma"
customPrismaImportPath = "../client"
}

This will replace the standard, default system of detecting Prisma generator output folder, based on the node_modules presence in the Prisma output option.

The custom Prisma import path will be used in all generated files, treated as a relative path to the output folder of typegraphql-prisma generator. This means the paths will be prepended with appropriate '../' for files in nested directories, like resolvers/outputs.

- + \ No newline at end of file diff --git a/docs/advanced/emit-blocks/index.html b/docs/advanced/emit-blocks/index.html index 4f27e385..1ed60790 100644 --- a/docs/advanced/emit-blocks/index.html +++ b/docs/advanced/emit-blocks/index.html @@ -4,14 +4,14 @@ Emit only selected blocks | TypeGraphQL Prisma - +

Emit only selected blocks

If you don't want to have generated all the CRUD API with all resolvers, arguments, inputs, outputs, models, etc., you can provide an emitOnly generator option, which accepts an array of values: enums, models, crudResolvers, relationResolvers, inputs or outputs, e.g.:

generator typegraphql {
provider = "typegraphql-prisma"
emitOnly = ["models", "inputs"]
}

This way the generator will emit only the parts that you're interested in, like models and inputs but without outputs or resolvers.

note

Be aware that e.g. models requires enums in order to compile. So sometimes you will receive more generated items than only those listed in emitOnly, especially when it comes to crudResolvers that requires almost all the pieces being generated.

- + \ No newline at end of file diff --git a/docs/advanced/emit-id-type/index.html b/docs/advanced/emit-id-type/index.html index 23fd006e..fe9a5007 100644 --- a/docs/advanced/emit-id-type/index.html +++ b/docs/advanced/emit-id-type/index.html @@ -4,14 +4,14 @@ Emit ID fields with type | TypeGraphQL Prisma - +

Emit ID fields with type

By default, TypeGraphQL Prisma generator emits GraphQL types for fields with the underlying data types, like Int or String scalars.

However, in some cases like when using GraphQL Relay, you may want to emit the ID GraphQL scalar type for those fields. To accomplish this, use the emitIdAsIDType generator option:

generator typegraphql {
provider = "typegraphql-prisma"
emitIdAsIDType = true
}

It will generate then the id fields using the TypeGraphQL.ID GraphQL scalar, e.g.:

@TypeGraphQL.ObjectType("Post", {})
export class Post {
@TypeGraphQL.Field(_type => TypeGraphQL.ID, {
nullable: false,
})
uuid!: string;

// ...
}
- + \ No newline at end of file diff --git a/docs/advanced/emit-is-abstract/index.html b/docs/advanced/emit-is-abstract/index.html index c286991f..f960fc2c 100644 --- a/docs/advanced/emit-is-abstract/index.html +++ b/docs/advanced/emit-is-abstract/index.html @@ -4,7 +4,7 @@ Emit `isAbstract` decorator option | TypeGraphQL Prisma - + @@ -12,7 +12,7 @@

Emit `isAbstract` decorator option

By default, TypeGraphQL Prisma generator aims to work with newest release of TypeGraphQL. However, for backward compatibility reasons, there are some config options introduced.

One of such options is emitIsAbstract generator option:

generator typegraphql {
provider = "typegraphql-prisma"
emitIsAbstract = true
}

When this option is set to true, it generates isAbstract: true decorator option for @ObjectType (models, outputs) and @InputType classes:

@TypeGraphQL.ObjectType("Post", {
isAbstract: true,
})
export class Post {
@TypeGraphQL.Field(_type => TypeGraphQL.ID, {
nullable: false,
})
uuid!: string;

// ...
}

This decorator option prevents from emitting those types in GraphQL schema if they are not referenced directly in the other types consumed by resolvers. It only matters if you use the resolvers auto discovery feature (e.g. resolvers: ["./src/**/*.resolver.ts"]), that was supported in TypeGraphQL up to the v2.0.0-beta.1 and removed in newer releases.

Hence this option is set to false by default, so if you still using some old version of TypeGraphQL together with resolvers auto discovery feature, you need to enable emitIsAbstract = true in your Prisma schema.

- + \ No newline at end of file diff --git a/docs/advanced/emit-redundant-types-info/index.html b/docs/advanced/emit-redundant-types-info/index.html index bfb0d37f..eac953f5 100644 --- a/docs/advanced/emit-redundant-types-info/index.html +++ b/docs/advanced/emit-redundant-types-info/index.html @@ -4,13 +4,13 @@ Emit redundant types info | TypeGraphQL Prisma - +

Emit redundant types info

By default, typegraphql-prisma tries to minimize the generated LOC by omitting the redundant types info.

However, if you need to have all the types info generated, you can use the emitRedundantTypesInfo generator option:

generator typegraphql {
provider = "typegraphql-prisma"
emitRedundantTypesInfo = true
}

By using this option, the generated code will have all the types info emitted in a form of decorator payload (@Args(_type => AggregateCategoryArgs)), even if it's redundant and not necessary.

However, thanks to this, you can use any other compiler that does not supports type metadata, like esbuild, so you're not limited to using standard Typescript compiler with emitDecoratorMetadata option enabled.

- + \ No newline at end of file diff --git a/docs/advanced/exposing-actions/index.html b/docs/advanced/exposing-actions/index.html index d91f0f7e..47d0578f 100644 --- a/docs/advanced/exposing-actions/index.html +++ b/docs/advanced/exposing-actions/index.html @@ -4,14 +4,14 @@ Exposing selected Prisma actions only | TypeGraphQL Prisma - +

Exposing selected Prisma actions only

If you want to expose only certain Prisma actions, like findManyUser or createOneUser, you can import resolver classes only for them, instead of the whole model XYZCrudResolver. Then you just have to put them into the buildSchema:

import {
User,
FindManyUserResolver,
CreateUserResolver,
UserRelationsResolver,
} from "@generated/type-graphql";

const schema = await buildSchema({
resolvers: [
CustomUserResolver,
FindManyUserResolver,
CreateUserResolver,
UserRelationsResolver,
],
validate: false,
});
- + \ No newline at end of file diff --git a/docs/advanced/exposing-models/index.html b/docs/advanced/exposing-models/index.html index 123fae7d..234ba549 100644 --- a/docs/advanced/exposing-models/index.html +++ b/docs/advanced/exposing-models/index.html @@ -4,13 +4,13 @@ Exposing selected models Prisma CRUD actions | TypeGraphQL Prisma - +

Exposing selected models Prisma CRUD actions

If you want to expose only CRUD Prisma actions for selected models, you can import crud resolver classes only for that models, instead of the all-in-one resolvers object.

Then you just have to put them into the buildSchema:

import { UserCrudResolver, PostCrudResolver } from "@generated/type-graphql";

const schema = await buildSchema({
resolvers: [CustomUserResolver, UserCrudResolver, PostCrudResolver],
validate: false,
});

However, if you also want to have relations like User -> posts emitted in schema, you need to import also the relations resolvers and register them in your buildSchema call:

import {
User,
UserRelationsResolver,
UserCrudResolver,
} from "@generated/type-graphql";

const schema = await buildSchema({
resolvers: [CustomUserResolver, UserRelationsResolver, UserCrudResolver],
validate: false,
});
- + \ No newline at end of file diff --git a/docs/advanced/hiding-field/index.html b/docs/advanced/hiding-field/index.html index f33efb95..c9be36ed 100644 --- a/docs/advanced/hiding-field/index.html +++ b/docs/advanced/hiding-field/index.html @@ -4,7 +4,7 @@ Hiding Prisma model field in GraphQL schema | TypeGraphQL Prisma - + @@ -13,7 +13,7 @@ To achieve this, just put the @TypeGraphQL.omit doc line above the model field definition in schema.prisma file, e.g:

model User {
id Int @default(autoincrement()) @id
email String @unique
/// @TypeGraphQL.omit(output: true)
password String
posts Post[]
}

Thanks to that, the field won't show up in the GraphQL schema representation:

type User {
id: Int!
email: String!
posts: [Post!]!
}

Hiding field in input types

However, the prisma model field will be still visible in all input types, like UserWhereInput or UserCreateInput:

input UserCreateInput {
email: String!
password: String!
posts: PostCreateManyWithoutAuthorInput!
}

In order to hide the input fields as well, you need to provide the input: true option to @TypeGraphQL.omit:

model User {
id Int @default(autoincrement()) @id
email String @unique
/// @TypeGraphQL.omit(output: true, input: true)
password String
posts Post[]
}

So that the field won't show anymore in all model-related input types, like UserCreateInput:

input UserCreateInput {
email: String!
posts: PostCreateManyWithoutAuthorInput!
}

Hiding field in specific input types

If you need more control over hiding field in input types, you can select input kinds by passing an array:

model User {
id Int @default(autoincrement()) @id
email String @unique
/// @TypeGraphQL.omit(input: ["update", "where", "orderBy"])
password String
posts Post[]
}

The available options are: "create","update", "where" and "orderBy".

Omit fields by default

In some cases, it might become repetitive to add @TypeGraphQL.omit to every field you want to hide. That's why you can set in generator options to omit selected fields by default.

Basically, there are two options you can set in - omitInputFieldsByDefault and omitOutputFieldsByDefault. They both accept an array of field names:

generator typegraphql {
provider = "typegraphql-prisma"
omitInputFieldsByDefault = ["createdAt", "updatedAt"]
omitOutputFieldsByDefault = ["password"]
}

The list is then used to compare against each model to find matching fields and apply the default omit settings to hide those fields.

Unfortunately, the Prisma parser for generator options is very limited and doesn't support complex objects, so for now the functionality is limited just to boolean-like behavior, with no options for granular control like input: ["update", "where", "orderBy"].

Overriding default omit settings

However, if you want to override the global default omit setting, you can just pass false to the @TypeGraphQL.omit, e.g.:

model User {
id Int @default(autoincrement()) @id
email String @unique
/// @TypeGraphQL.omit(output: false)
password String
posts Post[]
}

This way, the field will be still emitted in the GraphQL output type, even if the omitOutputFieldsByDefault was set to "password".

- + \ No newline at end of file diff --git a/docs/advanced/override-plural/index.html b/docs/advanced/override-plural/index.html index 96209630..0348b5c2 100644 --- a/docs/advanced/override-plural/index.html +++ b/docs/advanced/override-plural/index.html @@ -4,13 +4,13 @@ Overriding plural form of model name | TypeGraphQL Prisma - +

Overriding plural form of model name

In some cases, the noun used as the model name might not have a proper plural form. For example, the word "fish" is not pluralized to "fishes". In such cases, you can override the plural form by adding a plural argument to the @@TypeGraphQL.type comment attribute, e.g.:

/// @@TypeGraphQL.type(plural: "StaffMembers")
model Staff {
id Int @id @default(autoincrement())
name String @unique
}

This way, the generated resolvers for Staff model will use the plural form of StaffMembers, so that it won't generate anymore actions named findManyStaff or findUniqueStaff as it would do by default, e.g.:

@TypeGraphQL.Resolver(_of => Staff)
export class StaffCrudResolver {
@TypeGraphQL.Query(_returns => [Staff], {
nullable: false,
})
async staffMembers(
@TypeGraphQL.Ctx() ctx: any,
@TypeGraphQL.Info() info: GraphQLResolveInfo,
@TypeGraphQL.Args() args: FindManyStaffArgs,
): Promise<Staff[]> {
const { _count } = transformFields(graphqlFields(info as any));
return getPrismaFromContext(ctx).staff.findMany({
...args,
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
});
}

@TypeGraphQL.Query(_returns => Staff, {
nullable: true,
})
async staff(
@TypeGraphQL.Ctx() ctx: any,
@TypeGraphQL.Info() info: GraphQLResolveInfo,
@TypeGraphQL.Args() args: FindUniqueStaffArgs,
): Promise<Staff | null> {
const { _count } = transformFields(graphqlFields(info as any));
return getPrismaFromContext(ctx).staff.findUnique({
...args,
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
});
}
}
- + \ No newline at end of file diff --git a/docs/advanced/overriding-object-decorator/index.html b/docs/advanced/overriding-object-decorator/index.html index 5665eb0a..4ef91772 100644 --- a/docs/advanced/overriding-object-decorator/index.html +++ b/docs/advanced/overriding-object-decorator/index.html @@ -4,14 +4,14 @@ Overriding generated @ObjectType decorator for model | TypeGraphQL Prisma - +

Overriding generated @ObjectType decorator for model

By default, typegraphql-prisma generator emits TypeGraphQL classes for models with all the decorators applied. Due to the nature of TypeGraphQL, we can't just easily override or replace the applied decorators, so we have to use a workaround.

First, we need to omit registering the type class by TypeGraphQL, using the @@TypeGraphQL.omit(output: true) directive, e.g:

/// @@TypeGraphQL.omit(output: true)
model User {
id Int @default(autoincrement()) @id
email String @unique
}

This way the generated class won't have the @TypeGraphQL@ObjectType() decorator applied:

export class User {
@TypeGraphQL.Field(_type => String, {
nullable: false,
})
id!: string;

@TypeGraphQL.Field(_type => String, {
nullable: false,
})
email!: string;
}

So, we can register our own version of the decorator using applyModelsEnhanceMap feature:

applyModelsEnhanceMap({
User: {
class: [
ObjectType({
description: "Generated omitted type with custom description",
}),
],
},
});
caution

Be aware that using omit without applyModelsEnhanceMap might result in a runtime error, because the generated class won't have any decorators applied while still being referenced in resolvers as output type.

If we run the GraphQL server with such adjustments, we will get the following output in generated schema file:

"""
Generated omitted type with custom description
"""
type User {
id: ID!
email: String!
}
- + \ No newline at end of file diff --git a/docs/advanced/renaming-field/index.html b/docs/advanced/renaming-field/index.html index 9851dcb9..418743f8 100644 --- a/docs/advanced/renaming-field/index.html +++ b/docs/advanced/renaming-field/index.html @@ -4,14 +4,14 @@ Changing exposed model type field name | TypeGraphQL Prisma - +

Changing exposed model type field name

You can also change the name of the model type fields exposed in GraphQL Schema. To achieve this, just put the @TypeGraphQL.field doc line above the model field definition in schema.prisma file, e.g:

model User {
id Int @default(autoincrement()) @id
/// @TypeGraphQL.field(name: "emailAddress")
email String @unique
posts Post[]
}

This will result in the following GraphQL schema representation:

type User {
id: Int!
emailAddress: String!
posts: [Post!]!
}

All generated CRUD and relations resolvers fully support this feature and they map under the hood the original prisma property to the renamed field exposed in schema.

The same goes to the resolvers input types - they will also be emitted with changed field name, e.g.:

input UserCreateInput {
emailAddress: String!
posts: PostCreateManyWithoutAuthorInput
}

The emitted input type classes automatically map the provided renamed field values from GraphQL query into proper Prisma input properties out of the box.

- + \ No newline at end of file diff --git a/docs/advanced/renaming-model/index.html b/docs/advanced/renaming-model/index.html index 85e1fe44..ee4a7cd9 100644 --- a/docs/advanced/renaming-model/index.html +++ b/docs/advanced/renaming-model/index.html @@ -4,14 +4,14 @@ Changing exposed model type name | TypeGraphQL Prisma - +

Changing exposed model type name

You can also change the name of the model types exposed in GraphQL Schema. To achieve this, just put the @@TypeGraphQL.type doc line above the model definition in schema.prisma file, e.g:

/// @@TypeGraphQL.type(name: "Client")
model User {
id Int @default(autoincrement()) @id
email String @unique
posts Post[]
}

Be aware that this feature changes the name everywhere in the schema, so you can import FindManyClientResolver (not FindManyUserResolver), as well as only ClientUpdateInput is available (not UserUpdateInput), which means that the GraphQL queries/mutations will also be renamed, e.g.:

type Mutation {
createOneClient(data: ClientCreateInput!): Client!
}
- + \ No newline at end of file diff --git a/docs/advanced/simple-inputs/index.html b/docs/advanced/simple-inputs/index.html index 57874e71..2437f7cc 100644 --- a/docs/advanced/simple-inputs/index.html +++ b/docs/advanced/simple-inputs/index.html @@ -4,14 +4,14 @@ Simple and flat inputs | TypeGraphQL Prisma - +

Simple and flat inputs

In version 2.6.0, Prisma released atomicNumberOperations preview feature that allows you to update scalar fields without checking the current value, e.g. increment or decrement a number value.

However, GraphQL does not support input unions, hence it's not possible to support both simple scalar fields and atomic operation inputs at the same time. So, if you prefer simplicity over more complex approach using nested inputs, you can provide the useSimpleInputs generator option:

generator typegraphql {
provider = "typegraphql-prisma"
output = "../prisma/generated/type-graphql"
useSimpleInputs = true
}

By using this option, instead of generating nested inputs with IntFieldUpdateOperationsInput or StringFieldUpdateOperationsInput as a field type, it will emit much simpler version of inputs for update operations - with just scalar values:

@TypeGraphQL.InputType("CategoryUpdateInput", {})
export class CategoryUpdateInput {
@TypeGraphQL.Field(_type => String, {
nullable: true,
})
name?: string | undefined;

@TypeGraphQL.Field(_type => String, {
nullable: true,
})
slug?: string | undefined;

@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
nullable: true,
})
number?: number | undefined;
}

Same goes to array fields and nested documents, when you're using MongoDB as your Prisma db provider. By using this option, instead of generating nested inputs with XYZEnvelopeInput or FooCreateBarInput as a field type, it will emit much simpler version of inputs:

@TypeGraphQL.InputType("UserUpdateInput", {})
export class UserUpdateInput {
@TypeGraphQL.Field(_type => [TypeGraphQL.Int], {
nullable: true,
})
luckyNumbers?: number[] | undefined;

@TypeGraphQL.Field(_type => UserAddressCreateInput, {
nullable: true,
})
address?: UserAddressCreateInput | undefined;
}
- + \ No newline at end of file diff --git a/docs/advanced/simple-resolvers/index.html b/docs/advanced/simple-resolvers/index.html index 37aad359..0312686c 100644 --- a/docs/advanced/simple-resolvers/index.html +++ b/docs/advanced/simple-resolvers/index.html @@ -4,13 +4,13 @@ Simple resolvers (performance) | TypeGraphQL Prisma - +

Simple resolvers (performance)

If you don't have any global middlewares and you want to tune the generated schema performance, you can turn on the simpleResolvers generator option:

generator typegraphql {
provider = "typegraphql-prisma"
simpleResolvers = true
}

It will generate then all the output type and model type classes with simpleResolvers: true option of @ObjectType decorator, which can improve performance of underlying field resolvers, e.g.:

@TypeGraphQL.ObjectType({
description: undefined,
simpleResolvers: true,
})
export class BatchPayload {
@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
nullable: false,
description: undefined,
})
count!: number;
}
- + \ No newline at end of file diff --git a/docs/advanced/unchecked-scalars/index.html b/docs/advanced/unchecked-scalars/index.html index 316c8a08..7d896aa0 100644 --- a/docs/advanced/unchecked-scalars/index.html +++ b/docs/advanced/unchecked-scalars/index.html @@ -4,13 +4,13 @@ Unchecked scalars input | TypeGraphQL Prisma - +

Unchecked scalars input

GraphQL does not support input unions, hence it's not possible to support both normal inputs and unchecked scalars input at the same time like the Prisma does.

If you prefer simplicity over more sophisticated solutions like connectOrCreate, you can to provide the useUncheckedScalarInputs generator option:

generator typegraphql {
provider = "typegraphql-prisma"
output = "../prisma/generated/type-graphql"
useUncheckedScalarInputs = true
}

This way there will be generate input classes with relation id fields, instead of the normal "nested" inputs for creating/updating relations, e.g.:

@TypeGraphQL.InputType({})
export class PostUncheckedCreateInput {
@TypeGraphQL.Field(_type => String, {
nullable: false,
})
title!: string;

@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
nullable: false,
})
authorId!: number;

@TypeGraphQL.Field(_type => TypeGraphQL.Int, {
nullable: true,
})
editorId?: number | undefined;
}
- + \ No newline at end of file diff --git a/docs/basics/configuration/index.html b/docs/basics/configuration/index.html index 726b291b..fed5e82d 100644 --- a/docs/basics/configuration/index.html +++ b/docs/basics/configuration/index.html @@ -4,13 +4,13 @@ Configuration | TypeGraphQL Prisma - +

Configuration

Creating generator block

After installation, you need to update your schema.prisma file and then add a new generator section below the client one:

datasource postgres {
provider = "postgresql"
url = env("DATABASE_URL")
}

generator client {
provider = "prisma-client-js"
}

generator typegraphql {
provider = "typegraphql-prisma"
}

Then run npx prisma generate - this will emit the generated TypeGraphQL classes to the @generated/type-graphql folder inside node_modules.

Changing output folder

When you want to emit the generated files into a different folder, you can configure the default output folder via the output config option, e.g.:

generator typegraphql {
provider = "typegraphql-prisma"
output = "../prisma/generated/type-graphql"
}

Emitting transpiled code

By default, when the output path contains node_modules, the generated code is transpiled - consist of *.js and *.d.ts files that are ready to use (import) in your code.

However, if you explicitly choose some other (non node_modules) folder in output config, the generated code will be emitted as a raw TS source code files which you can just use and import like your other source code files.

You can override that behavior by explicitly setting emitTranspiledCode config option:

generator typegraphql {
provider = "typegraphql-prisma"
output = "../prisma/generated/type-graphql"
emitTranspiledCode = true
}

Formatting generated code

By default, the generated code is formatted by TypeScript compiler while emitting.

However, if you prefer some other code style, you can provide formatGeneratedCode generator option to format the codebase with Prettier:

generator typegraphql {
provider = "typegraphql-prisma"
output = "../prisma/generated/type-graphql"
formatGeneratedCode = "prettier"
}

Prettier will look for the configuration file in your project tree and use it to format the generated code. If no config file detected, default settings will be applied.

caution

Be aware that formatting code by Prettier has a quite huge impact on the generation time, so use it with caution.

If you git-ignore the generated files or you don't want to read the generated source code, you can ignore the generated code style and disable the formatting at all - by providing false value to formatGeneratedCode generator option:

generator typegraphql {
provider = "typegraphql-prisma"
output = "../prisma/generated/type-graphql"
formatGeneratedCode = false
}

This way you can save even up to 33% of the generation process time.

info

When the generator is configured to emit transpiled code, the generated JS code is always formatted by TypeScript compiler and you can't change it to Prettier or disable the formatting by the formatGeneratedCode option.

- + \ No newline at end of file diff --git a/docs/basics/installation/index.html b/docs/basics/installation/index.html index 8a8344bc..2fbb9a1b 100644 --- a/docs/basics/installation/index.html +++ b/docs/basics/installation/index.html @@ -3,16 +3,17 @@ -Installation | TypeGraphQL Prisma - +Installation | TypeGraphQL Prisma +
-

Installation

info

Be aware that due to usage of some ES2019 and newer Node.js features, you also have to use Node.js v12.4.0 or newer.

TypeGraphQL

First of all, you should perform all the steps described in the TypeGraphQL installation instruction:

https://typegraphql.com/docs/installation.html

typegraphql-prisma generator

After that, you have to install the generator, as a dev dependency:

npm i -D typegraphql-prisma

Furthermore, typegraphql-prisma requires Prisma to work properly, so please install Prisma dependencies if you don't have it already installed:

npm i -D prisma
npm i @prisma/client
caution

Be aware that typegraphql-prisma is designed to work with a selected versions of prisma.

Please make sure you use prisma and @prisma/client of version matching ^4.15.0. -Otherwise, the runtime check will report an error when you run the generator.

Additional dependencies

You also need to install the GraphQL Scalars library (to support the Prisma Json, BigInt and Byte types):

npm i graphql-scalars

In order to properly support the aggregate and group by queries, the graphql-fields package is used, so it also has to be installed:

npm i graphql-fields @types/graphql-fields

Finally, please also install the tslib package, which is required for applying the additional decorators properly:

npm i tslib

TypeScript configuration

As prisma emits multiple files, make sure you have your tsconfig set properly to "module": "commonjs":

{
"compilerOptions": {
"target": "es2018",
"module": "commonjs",
"lib": ["es2018", "esnext.asynciterable"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}

Otherwise you may experience runtime errors like ReferenceError: Cannot access 'BankAccountWhereInput' before initialization. +

Installation

info

Be aware that due to usage of some ES2022 and newer Node.js features, you also have to use Node.js v16.13.0 or newer.

TypeGraphQL

First of all, you should perform all the steps described in the TypeGraphQL installation instruction:

https://typegraphql.com/docs/installation.html

typegraphql-prisma generator

After that, you have to install the generator, as a dev dependency:

npm i -D typegraphql-prisma

Furthermore, typegraphql-prisma requires Prisma to work properly, so please install Prisma dependencies if you don't have it already installed:

npm i -D prisma
npm i @prisma/client
caution

Be aware that typegraphql-prisma is designed to work with a selected versions of Prisma. +This generator is designed to work and tested with the features of the 5.0.0 release.

You can update both prisma and @prisma/client to a newer version, matching ^5.0.0, like 5.4.2, in order to receive important bugfixes. +However, make sure you don't use the new features from a newer Prisma version, especially the ones behind a preview flag.

If you encounter a new Prisma feature not supported yet, please check on GitHub issues and create a new issue, if that wasn't already reported, and downgrade the Prisma version, if needed.

Additional dependencies

You also need to install the GraphQL Scalars library (to support the Prisma Json, BigInt and Byte types):

npm i graphql-scalars

In order to properly support the aggregate and group by queries, the graphql-fields package is used, so it also has to be installed:

npm i graphql-fields @types/graphql-fields

Finally, please also install the tslib package, which is required for applying the additional decorators properly:

npm i tslib

TypeScript configuration

As prisma emits multiple files, make sure you have your tsconfig set properly to "module": "commonjs":

{
"compilerOptions": {
"target": "es2022",
"module": "commonjs",
"lib": ["es2022"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}

Otherwise you may experience runtime errors like ReferenceError: Cannot access 'BankAccountWhereInput' before initialization. It's because those generated files rely on each other, so commonjs is needed to handle that cyclic imports.

- + \ No newline at end of file diff --git a/docs/basics/nest-js/index.html b/docs/basics/nest-js/index.html index 66bf569f..be483f18 100644 --- a/docs/basics/nest-js/index.html +++ b/docs/basics/nest-js/index.html @@ -4,13 +4,13 @@ Nest JS | TypeGraphQL Prisma - +

Nest JS

typegraphql-nestjs

In order to use generated types and resolvers classes in NestJS, you need to use the official typegraphql-nestjs package.

This module allows for basic integration of TypeGraphQL with NestJS, so you can use the generated TypeGraphQL classes to create a GraphQL API in NestJS.

You can find an example in the examples/4-nest-js folder.

caution

Due to difference between TypeGraphQL and NestJS decorators, typegraphql-prisma doesn't work anymore with @nestjs/graphql from version 7.0.

- + \ No newline at end of file diff --git a/docs/basics/prisma-version/index.html b/docs/basics/prisma-version/index.html index 8555fbb1..82dd3dec 100644 --- a/docs/basics/prisma-version/index.html +++ b/docs/basics/prisma-version/index.html @@ -4,7 +4,7 @@ Prisma version verification | TypeGraphQL Prisma - + @@ -13,7 +13,7 @@ By default, it checks if the installed Prisma version matches the required one using semver rules. So when you try to use other version, like a just published, new minor release (or the dev one), you will receive an error about wrong package version, e.g:

Error: Looks like an incorrect version "3.1.1" of the Prisma packages has been installed.
'typegraphql-prisma' works only with selected versions, so please ensure
that you have installed a version of Prisma that meets the requirement: "~3.0.1".
Find out more about that requirement in docs:
https://prisma.typegraphql.com/docs/basics/prisma-version

The reason of such restriction is that typegraphql-prisma heavily relies on the DMMF and Prisma generators feature which are not considered a public API, so that there's no guarantee about them having no breaking changes in minor releases. In plenty of previous releases, changes done in Prisma and DMMF impacted typegraphql-prisma a lot, so that the generator have produced e.g. invalid classes or even have broken at all.

So in order to prevent typegraphql-prisma users from creating issues on GitHub, when they install the latest version of Prisma, such version check has been implemented and is performed by default. However, when you are sure what you're doing, you can lift the Prisma version restriction and try to use the typegraphql-prisma with the newer Prisma version.

Lifting Prisma version restriction

If you want or need to try other version of Prisma, you can use SKIP_PRISMA_VERSION_CHECK env variable to suppress that error:

SKIP_PRISMA_VERSION_CHECK=true npx prisma generate

This way there will be no Prisma version check performed and no error thrown. However, using this mode means you are not allowed to report any bug issues as only selected Prisma versions are supported by the typegraphql-prisma generator.

- + \ No newline at end of file diff --git a/docs/basics/usage/index.html b/docs/basics/usage/index.html index 7c60df58..c0c50d78 100644 --- a/docs/basics/usage/index.html +++ b/docs/basics/usage/index.html @@ -4,14 +4,14 @@ Usage | TypeGraphQL Prisma - +

Usage

Having installed all the deps and configured the Prisma generator, let's see the capabilities of typegraphql-prisma.

Showcase

Let's assume you have this statements in your Prisma schema:

prisma/schema.prisma
enum UserKind {
NORMAL
ADMIN
}

model User {
id String @default(cuid()) @id @unique
email String @unique
age Int?
kind UserKind
}

It will generate a User class (with TypeGraphQL decorators) in the output folder and an enum:

generated/type-graphql/enums/UserKind.ts
export enum UserKind {
NORMAL = "NORMAL",
ADMIN = "ADMIN",
}
TypeGraphQL.registerEnumType(UserKind, {
name: "UserKind",
description: undefined,
});
generated/type-graphql/models/User.ts
@TypeGraphQL.ObjectType({
description: undefined,
})
export class User {
@TypeGraphQL.Field(_type => String, {
nullable: false,
description: undefined,
})
id!: string;

@TypeGraphQL.Field(_type => String, {
nullable: false,
description: undefined,
})
email!: string;

@TypeGraphQL.Field(_type => Int, {
nullable: true,
description: undefined,
})
age?: number | null;

@TypeGraphQL.Field(_type => UserKind, {
nullable: false,
description: undefined,
})
kind!: UserKind;
}

You can import them and use normally as a type or an explicit type in your resolvers, e.g:

src/custom-resolver.ts
import {
User,
UserWhereUniqueInput,
UserKind,
} from "../generated/type-graphql";

@Resolver()
class CustomUserResolver {
@Mutation(() => User)
changeUserKind(
@Arg("where") where: UserWhereUniqueInput,
@Arg("kind") kind: UserKind,
) {
log.info("Changing user kind", { where, kind });
return prisma.user.update({ where, data: { kind } });
}
}

However, it will also generates a whole bunch of stuffs based on your schema.prisma file - not only models classes and enums but also input types, arguments, CRUD resolvers and relations resolver.

Main concept

The design goal of TypeGraphQL Prisma integration is to generate all the building blocks that you can then use to quickly build your domain logic using custom resolvers.

However, it can also generate some resolvers which might be handy especially on the prototyping phase or on the early stage, when the customization options are not limiting yet.

CRUD resolvers

typegraphql-prisma generator also can emit CRUD resolvers. The API is almost 1:1 matching with the PrismaClient API and supports this following methods with their args:

  • findUnique
  • findFirst
  • findMany
  • create
  • createMany
  • update
  • updateMany
  • delete
  • deleteMany
  • upsert
  • aggregate
  • groupBy

An example of a crud resolver file content:

generated/type-graphql/resolvers/crud/User/UserCrudResolver.ts
@TypeGraphQL.Resolver(_of => User)
export class UserCrudResolver {
@TypeGraphQL.Query(_returns => [User], {
nullable: false,
})
async users(
@TypeGraphQL.Ctx() ctx: any,
@TypeGraphQL.Info() info: GraphQLResolveInfo,
@TypeGraphQL.Args() args: FindManyUserArgs,
): Promise<User[]> {
const { _count } = transformFields(graphqlFields(info as any));
return getPrismaFromContext(ctx).user.findMany({
...args,
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
});
}

@TypeGraphQL.Mutation(_returns => User, {
nullable: false,
})
async createUser(
@TypeGraphQL.Ctx() ctx: any,
@TypeGraphQL.Info() info: GraphQLResolveInfo,
@TypeGraphQL.Args() args: CreateUserArgs,
): Promise<User> {
const { _count } = transformFields(graphqlFields(info as any));
return getPrismaFromContext(ctx).user.create({
...args,
...(_count && transformCountFieldIntoSelectRelationsCount(_count)),
});
}

// more methods goes here...
}
info

By default, the method names will be mapped to a GraphQL idiomatic ones (like findManyUser -> users).

You can opt-in to use original names by providing useOriginalMapping = true generator option.

Relations resolvers

TypeGraphQL Prisma integration also generates resolvers that are resolving the relations between Prisma models. Thanks to that, you don't need to write any field resolvers by yourself in order to register relation fields in GraphQL schema.

generated/type-graphql/resolvers/relations/User/UserRelationsResolver.ts
@TypeGraphQL.Resolver(_of => User)
export class UserRelationsResolver {
@TypeGraphQL.FieldResolver(_type => [Post], {
nullable: false,
})
async posts(
@TypeGraphQL.Root() user: User,
@TypeGraphQL.Ctx() ctx: any,
@TypeGraphQL.Args() args: UserPostsArgs,
): Promise<Post[]> {
return getPrismaFromContext(ctx)
.user.findUnique({
where: {
id: user.id,
},
})
.posts(args);
}
}

The generated relation resolvers also supports providing arguments that allows you to filter, sort and paginate over the relation list items.

Bootstrapping

The fastest way to expose all Prisma CRUD actions is to import resolvers from the output folder and just use it in the buildSchema function known from TypeGraphQL:

import { resolvers } from "@generated/type-graphql";

const schema = await buildSchema({
resolvers,
validate: false,
});

With this approach you will emit all CRUD actions and model relations in the schema.

If you need more control, you can import the crudResolvers and relationResolvers arrays separately:

import { crudResolvers, relationResolvers } from "@generated/type-graphql";

to even transform them dynamically (e.g. excluding all with User in name).

Context configuration

When using the generated resolvers, you have to first provide the PrismaClient instance into the context under prisma key, to make it available for the crud and relations resolvers.

Below you can find an example using Apollo Server V4:

import { PrismaClient } from "@prisma/client";
import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone";

const prisma = new PrismaClient();

const server = new ApolloServer<MyContext>({
schema, // from previous step
});
const { url } = await startStandaloneServer(server, {
context: () => ({ prisma }),
listen: { port: 4000 },
});

But you can also use any other GraphQL server library, like graphql-yoga v3:

import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

const yoga = createYoga<{}, MyContext>({
schema, // from previous step
context: () => ({ prisma }),
});
- + \ No newline at end of file diff --git a/docs/category/advanced/index.html b/docs/category/advanced/index.html index 8b6d7d29..b5551762 100644 --- a/docs/category/advanced/index.html +++ b/docs/category/advanced/index.html @@ -4,13 +4,13 @@ Advanced concept | TypeGraphQL Prisma - +

Advanced concept

Learn about the more advanced concepts!

- + \ No newline at end of file diff --git a/docs/category/basics/index.html b/docs/category/basics/index.html index 387d3cd5..80e7619b 100644 --- a/docs/category/basics/index.html +++ b/docs/category/basics/index.html @@ -4,13 +4,13 @@ Basic steps | TypeGraphQL Prisma - + - + + \ No newline at end of file diff --git a/docs/examples/index.html b/docs/examples/index.html index 6df60958..c4ca7266 100644 --- a/docs/examples/index.html +++ b/docs/examples/index.html @@ -4,13 +4,13 @@ Examples | TypeGraphQL Prisma - +

Examples

In the GitHub repository you can find a few examples of using the TypeGraphQL Prisma integration:

  1. Prototyping - the workflow of using the generator that creates TypeGraphQL artifacts from Prisma schema and creating a GraphQL schema with all CRUD operation

    https://github.com/MichalLytek/typegraphql-prisma/tree/main/examples/1-prototyping

  2. Basic - demonstrating how you can create custom methods or custom fields

    https://github.com/MichalLytek/typegraphql-prisma/tree/main/examples/2-basic

  3. Picking Actions - demonstrating how you can choose certain Prisma actions to be exposed in the GraphQL schema

    https://github.com/MichalLytek/typegraphql-prisma/tree/main/examples/3-picking-actions

  4. Nest JS - showcase of combining typegraphql-prisma with typegraphql-nestjs to expose TypeGraphQL-Prisma2 artifacts as GraphQL schema using Nest JS

    https://github.com/MichalLytek/typegraphql-prisma/tree/main/examples/4-nest-js

To run some example, simply go to the subdirectory, install the dependencies (npm i) and then start the server (npm start).

Each subdirectory contains a examples.gql file with a predefined GraphQL queries that you can use in GraphQL Playground (http://localhost:4000) and play with them by modifying it's shape and data.

- + \ No newline at end of file diff --git a/docs/intro/index.html b/docs/intro/index.html index f6379d2d..e2738d87 100644 --- a/docs/intro/index.html +++ b/docs/intro/index.html @@ -4,13 +4,13 @@ Introduction | TypeGraphQL Prisma - +

Introduction

Let's discover TypeGraphQL Prisma in less than 3 minutes.

What it is?

The typegraphql-prisma package provides a TypeGraphQL integration with Prisma.

It generates the type classes and CRUD resolvers based on the Prisma schema, so you can execute complex queries or mutations that corresponds to the Prisma actions, without having to write any code for that.

Getting Started

To make use of the prisma integration, first you need to add a new generator to the schema.prisma file:

generator typegraphql {
provider = "typegraphql-prisma"
}

Then, after running prisma generate you can import the generated resolvers classes and use them to build your GraphQL schema:

import { resolvers } from "@generated/type-graphql";

const schema = await buildSchema({
resolvers,
validate: false,
});

When you expose that schema over the HTTP, following the bootstrap guide, you will be able to execute a complex query, that talks with the real database, in just a few minutes!

query GetSomeUsers {
users(where: { email: { contains: "prisma" } }, orderBy: { name: desc }) {
id
name
email
posts(take: 10, orderBy: { updatedAt: desc }) {
published
title
content
}
}
}

Sounds really easy and quick to setup, doesn't it? 😉

- + \ No newline at end of file diff --git a/index.html b/index.html index 6c40e8d7..9a7d335a 100644 --- a/index.html +++ b/index.html @@ -4,13 +4,13 @@ Home page | TypeGraphQL Prisma - +
TypeGraphQL logoPrisma logoPrisma logo

TypeGraphQL Prisma

Prisma generator to emit TypeGraphQL type classes and CRUD resolvers from your Prisma schema

Good for Prototyping

Designed from the ground up to be used to get your GraphQL CRUD API up and running quickly - even in under 5 minutes!

Easily Customizable

Configure which actions should be exposed, hide selected models fields, give alternative names to the types... and many more!

Extensible Design

Reuse generated classes to create custom resolvers with ease. Combine them with generated CRUD resolvers to compose the GraphQL API of your dreams.

- + \ No newline at end of file diff --git a/search/index.html b/search/index.html index eddb51a8..04ea03a4 100644 --- a/search/index.html +++ b/search/index.html @@ -4,13 +4,13 @@ Search the documentation | TypeGraphQL Prisma - +

Search the documentation

- + \ No newline at end of file