{"_id":"@codejamninja/typegraphql-nestjs","_rev":"1-32b813d2b9254e9550cb2fdeb9a8b18c","name":"@codejamninja/typegraphql-nestjs","dist-tags":{"latest":"0.2.3-0"},"versions":{"0.2.3-0":{"name":"@codejamninja/typegraphql-nestjs","version":"0.2.3-0","author":{"name":"Michał Lytek","url":"https://github.com/MichalLytek"},"scripts":{"build":"tsc","check:type":"tsc --noEmit","test":"jest"},"peerDependencies":{"@nestjs/common":"^7.4.2","@nestjs/core":"^7.4.2","@nestjs/graphql":"^7.6.0","type-graphql":"^1.0.0"},"dependencies":{"tslib":"^2.0.1"},"devDependencies":{"@nestjs/common":"^7.4.2","@nestjs/core":"^7.4.2","@nestjs/graphql":"^7.6.0","@nestjs/platform-fastify":"^7.4.2","@nestjs/testing":"^7.4.2","@types/jest":"^26.0.10","@types/node":"^14.6.0","apollo-server-fastify":"^2.16.1","class-validator":"^0.12.2","graphql":"^15.3.0","graphql-tools":"^6.0.18","husky":"^4.2.5","jest":"^26.4.2","lint-staged":"^10.2.11","prettier":"^2.0.5","reflect-metadata":"^0.1.13","ts-jest":"^26.2.0","ts-node":"^9.0.0","type-graphql":"^1.0.0","typescript":"^4.0.2"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"src/**/*.ts":["prettier --write"],"**/*.md":["prettier --write"]},"main":"./dist/index.js","types":"./dist/index.d.ts","description":"Basic integration of TypeGraphQL in NestJS. Allows to use TypeGraphQL features while integrating with NestJS modules system and dependency injector.","license":"MIT","funding":{"type":"opencollective","url":"https://opencollective.com/typegraphql"},"repository":{"type":"git","url":"git+https://github.com/MichalLytek/typegraphql-nestjs.git"},"bugs":{"url":"https://github.com/MichalLytek/typegraphql-nestjs/issues"},"keywords":["type-graphql","nest","nestjs","graphql"],"engines":{"node":">= 10.3"},"gitHead":"9c175dd3eac2004d62a3d19d8e130de34fc083df","homepage":"https://github.com/MichalLytek/typegraphql-nestjs#readme","_id":"@codejamninja/typegraphql-nestjs@0.2.3-0","_nodeVersion":"12.17.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-50q0SlB+oVELHkn43n5Zs/8IpCSwrr9zsy9wVMvQc+MLN/phS5QVoKHMt9t7h4x6aLrqORP8rCJQFSBP0tH9sw==","shasum":"fcc3abde37859ba8df072123c2272ea4f2c5e8aa","tarball":"https://registry.npmjs.org/@codejamninja/typegraphql-nestjs/-/typegraphql-nestjs-0.2.3-0.tgz","fileCount":13,"unpackedSize":16638,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfaWkZCRA9TVsSAnZWagAA20IP/jOyw82W8pjxzP9Oj2iJ\nxf5NC0Zq17branPfGvpdvN9Wwzte88AdlG0ZaO60g1cs4iOX7mwFYwPd4ibM\nNIJxQsKAAQckE3RYIm7K+pRpTU9GfskSsz7he6gOe7vEFY5amMKAIdPfYseh\nvCpuQK1klQ+gzphJ7tCTjvHkF/cZziLH3yuIRaEBgtwA8HrYYocSwerNhTGA\npSx/iFd60UY5pxJ3Aa/Sx5k0zNeEE125thvW2lJOBx0RKvZT04bBYKhionGz\nBGZOexRQRm+p6uhnOD+rgZnXWWZSwpnZZlByQWpqljGSvhh0SxZew3IYXUvm\n9sjksSVRBGb8t8QXW8+80IUNypeTRcWBlXsX/iWrN312IKji0aMIBcvUqbEg\nfOg7vP2x1N2qzDinhN2rNaE6rFYuZ43NsmB2L7+sg6v4Peb+TNduCN+3Ak1p\nNDi9pPGLqAD/RgdKEIxvDWrvfA9IPWS99rohdDDCJI37/ZEpqZlISdtutOyo\nOEumYlvz5opWSHcqI3TPE8MkCXGBhS7eA765AIsIAcpZXNI9a85ENbD2h0Za\n48Ia6mM2KJeDjyHrrs2O8RtqBVvwjhzb7Oldhu7uWwJCO8WTSHjQWWEtNAZq\ntutgop+VxiBwzvYVlCkUPUURS3HZ4fBsrSqBIiLjKPrAGJrc9Uo7r2jwMbWI\n3kjn\r\n=yqGs\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD+pCOEwFlJKDanMMIBbWolZsaUgmqcAr8kn40l2eyL1AIgYAh6bGwX5BRkfcVUQ7eimMiBP8Z+UxjpJL8JgKUQYy0="}]},"maintainers":[{"name":"codejamninja","email":"jam@codejam.ninja"}],"_npmUser":{"name":"codejamninja","email":"jam@codejam.ninja"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/typegraphql-nestjs_0.2.3-0_1600743705259_0.22126890582803616"},"_hasShrinkwrap":false}},"time":{"created":"2020-09-22T03:01:45.221Z","0.2.3-0":"2020-09-22T03:01:45.401Z","modified":"2022-04-05T00:03:08.319Z"},"maintainers":[{"name":"codejamninja","email":"jam@codejam.ninja"}],"description":"Basic integration of TypeGraphQL in NestJS. Allows to use TypeGraphQL features while integrating with NestJS modules system and dependency injector.","homepage":"https://github.com/MichalLytek/typegraphql-nestjs#readme","keywords":["type-graphql","nest","nestjs","graphql"],"repository":{"type":"git","url":"git+https://github.com/MichalLytek/typegraphql-nestjs.git"},"author":{"name":"Michał Lytek","url":"https://github.com/MichalLytek"},"bugs":{"url":"https://github.com/MichalLytek/typegraphql-nestjs/issues"},"license":"MIT","readme":"<p align=\"center\">\n  <img alt=\"typegraphql logo\" src=\"https://raw.githubusercontent.com/MichalLytek/typegraphql-nestjs/master/typegraphql-logo.png\" width=\"300\" height=\"200\">\n  <img alt=\"nest logo\" src=\"https://nestjs.com/img/logo_text.svg\" width=\"300\" height=\"200\">\n</p>\n\n# TypeGraphQL NestJS Module\n\nBasic integration of [TypeGraphQL](https://typegraphql.com/) in [NestJS](https://nestjs.com/).\n\nAllows to use TypeGraphQL features while integrating with NestJS modules system and dependency injector.\n\n## Installation\n\nFirst, you need to instal the `typegraphql-nestjs` module along with `@nestjs/graphql`:\n\n```sh\nnpm i typegraphql-nestjs @nestjs/graphql\n```\n\nIf you haven't installed it yet, it's time to add `type-graphql` into the project:\n\n```sh\nnpm i type-graphql\n```\n\n## How to use?\n\nThe `typegraphql-nestjs` package exports `TypeGraphQLModule` dynamic module, which is based on the official NestJS `GraphQLModule`.\n\nIt exposes two static methods. The first one is `TypeGraphQLModule.forRoot()` which you should call on your root module, just like with `GraphQLModule`.\n\nThe only difference is that as its argument you can provide [typical TypeGraphQL `buildSchema` options](https://typegraphql.com/docs/bootstrap.html) like `emitSchemaFile` or `authChecker` apart from the [standard `GqlModuleOptions` from `@nestjs/graphql`](https://docs.nestjs.com/graphql/quick-start#installation) like `installSubscriptionHandlers` or `context`:\n\n```ts\nimport { Module } from \"@nestjs/common\";\nimport { TypeGraphQLModule } from \"typegraphql-nestjs\";\n\nimport RecipeModule from \"./recipe/module\";\nimport { authChecker } from \"./auth\";\n\n@Module({\n  imports: [\n    TypeGraphQLModule.forRoot({\n      emitSchemaFile: true,\n      validate: false,\n      authChecker,\n      dateScalarMode: \"timestamp\",\n      context: ({ req }) => ({ currentUser: req.user }),\n    }),\n    RecipeModule,\n  ],\n})\nexport default class AppModule {}\n```\n\nThen, inside the imported modules (like `RecipeModule`) you just need to register the resolvers classes in the module `providers` array:\n\n```ts\nimport { Module } from \"@nestjs/common\";\n\nimport RecipeResolver from \"./resolver\";\nimport RecipeService from \"./service\";\n\n@Module({\n  providers: [RecipeResolver, RecipeService],\n})\nexport default class RecipeModule {}\n```\n\nAnd that's it! 😁\n\nNotice that the resolvers classes are automatically inferred from your submodules `providers` array, so you don't need to specify `resolvers` property from TypeGraphQL `buildSchema` options inside `TypeGraphQLModule.forRoot()`.\n\nIn case of need to provide `orphanedTypes` setting, you should use `TypeGraphQLModule.forFeature()`. The recommended place for that is in the module where the orphaned type (like `SuperRecipe`) belongs:\n\n```ts\nimport { Module } from \"@nestjs/common\";\nimport { TypeGraphQLModule } from \"typegraphql-nestjs\";\n\nimport RecipeResolver from \"./resolver\";\nimport RecipeService from \"./service\";\nimport { SuperRecipe } from \"./types\";\n\n@Module({\n  imports: [\n    TypeGraphQLModule.forFeature({\n      orphanedTypes: [SuperRecipe],\n    }),\n  ],\n  providers: [RecipeResolver, RecipeService],\n})\nexport default class RecipeModule {}\n```\n\nUsing `.forFeature()` ensures proper schemas isolation and automatically supply `orphanedTypes` option for underlying `buildSchema` from TypeGraphQL - again, there's no need to provide it manually in `.forRoot()` options.\n\n## Caveats\n\nWhile this integration provides a way to use TypeGraphQL with NestJS modules and dependency injector, for now it doesn't support [other NestJS features](https://docs.nestjs.com/graphql/tooling) like guards, interceptors, filters and pipes.\n\nTo achieve the same goals, you can use standard TypeGraphQL equivalents - middlewares, custom decorators, built-in authorization and validation.\n\nMoreover, with `typegraphql-nestjs` you can also take advantage of additional features (comparing to `@nestjs/graphql`) like [inline field resolvers](https://typegraphql.com/docs/resolvers.html#field-resolvers), [interface args and resolvers](https://typegraphql.com/docs/next/interfaces.html#resolvers-and-arguments), [query complexity](https://typegraphql.com/docs/complexity.html) or [Prisma 2 integration](https://github.com/MichalLytek/type-graphql/blob/prisma/Readme.md).\n\n## Examples\n\nYou can see some examples of the integration in this repo:\n\n1. [Basics](https://github.com/MichalLytek/typegraphql-nestjs/tree/master/examples/1-basics)\n\n   Basics of the integration, like `TypeGraphQLModule.forRoot` usage\n\n1. [Multiple Servers](https://github.com/MichalLytek/typegraphql-nestjs/tree/master/examples/2-multiple-servers)\n\n   Advanced usage of multiple schemas inside single NestJS app - demonstration of schema isolation in modules and `TypeGraphQLModule.forFeature` usage\n\n1. [Request scoped dependencies](https://github.com/MichalLytek/typegraphql-nestjs/tree/master/examples/3-request-scoped)\n\n   Usage of request scoped dependencies - retrieving fresh instances of resolver and service classes on every request (query/mutation)\n\nYou can run them by using `ts-node`, like `npx ts-node ./examples/1-basics/index.ts`.\n\nAll examples folders contain a `query.gql` file with some examples operations you can perform on the GraphQL servers.\n","readmeFilename":"README.md"}