diff --git a/README.md b/README.md index dd8986fb0..59b76749e 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,11 @@ A collection of Badass modules and utilities to help you level up your NestJS ap -| Project | Description | Version | Changelog | -| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- | -| [`@golevelup/nestjs-common`](./packages/common) | Common types, mixins | [![version](https://img.shields.io/npm/v/@golevelup/nestjs-common.svg)](https://www.npmjs.com/package/@golevelup/nestjs-common) | [changelog](./packages/common/CHANGELOG.md) | -| [`@golevelup/nestjs-discovery`](./packages/discovery) | `DiscoveryModule` for finding providers, controllers and method handlers from your NestJS app that have certain metadata | [![version](https://img.shields.io/npm/v/@golevelup/nestjs-discovery.svg)](https://www.npmjs.com/package/@golevelup/nestjs-discovery) | [changelog](./packages/discovery/CHANGELOG.md) | -| [`@golevelup/nestjs-rabbitmq`](./packages/rabbitmq) | A NestJS native module for RabbitMQ that supports both RPC and Publish/Subscribe messaging patterns | [![version](https://img.shields.io/npm/v/@golevelup/nestjs-rabbitmq.svg)](https://www.npmjs.com/package/@golevelup/nestjs-rabbitmq) | [changelog](./packages/rabbitmq/CHANGELOG.md) | -| [`@golevelup/nestjs-modules`](./packages/modules) | A Dynamic Module helper. Useful for configuring once and importing anywhere else | [![version](https://img.shields.io/npm/v/@golevelup/nestjs-modules.svg)](https://www.npmjs.com/package/@golevelup/nestjs-modules) | [changelog](./packages/modules/CHANGELOG.md) | +| Project | Description | Version | Changelog | +| ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | +| [`@golevelup/nestjs-common`](./packages/common) | Common types, mixins | [![version](https://img.shields.io/npm/v/@golevelup/nestjs-common.svg)](https://www.npmjs.com/package/@golevelup/nestjs-common) | [changelog](./packages/common/CHANGELOG.md) | +| [`@golevelup/nestjs-discovery`](./packages/discovery) | `DiscoveryModule` for finding providers, controllers and method handlers from your NestJS app that have certain metadata | [![version](https://img.shields.io/npm/v/@golevelup/nestjs-discovery.svg)](https://www.npmjs.com/package/@golevelup/nestjs-discovery) | [changelog](./packages/discovery/CHANGELOG.md) | +| [`@golevelup/nestjs-rabbitmq`](./packages/rabbitmq) | A NestJS native module for RabbitMQ that supports both RPC and Publish/Subscribe messaging patterns | [![version](https://img.shields.io/npm/v/@golevelup/nestjs-rabbitmq.svg)](https://www.npmjs.com/package/@golevelup/nestjs-rabbitmq) | [changelog](./packages/rabbitmq/CHANGELOG.md) | +| [`@golevelup/nestjs-modules`](./packages/modules) | A Dynamic Module helper. Useful for configuring once and importing anywhere else | [![version](https://img.shields.io/npm/v/@golevelup/nestjs-modules.svg)](https://www.npmjs.com/package/@golevelup/nestjs-modules) | [changelog](./packages/modules/CHANGELOG.md) | +| [`@golevelup/nestjs-hasura`](./packages/hasura) | Super charged Hasura Event Handlers and other utilities for seamlessly integrating Hasura with NestJS | [![version](https://img.shields.io/npm/v/@golevelup/nestjs-hasura.svg)](https://www.npmjs.com/package/@golevelup/nestjs-hasura) | [changelog](./packages/hasura/CHANGELOG.md) | +| [`@golevelup/nestjs-graphql-request`](./packages/graphql-request) | Dependency Injection for GraphQLClient. Make type safe requests to third party GQL APIs | [![version](https://img.shields.io/npm/v/@golevelup/nestjs-graphql-request.svg)](https://www.npmjs.com/package/@golevelup/nestjs-graphql-request) | [changelog](./packages/graphql-request/CHANGELOG.md) | diff --git a/packages/graphql-request/CHANGELOG.md b/packages/graphql-request/CHANGELOG.md new file mode 100644 index 000000000..e4d87c4d4 --- /dev/null +++ b/packages/graphql-request/CHANGELOG.md @@ -0,0 +1,4 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. diff --git a/packages/graphql-request/README.md b/packages/graphql-request/README.md new file mode 100644 index 000000000..902507e8e --- /dev/null +++ b/packages/graphql-request/README.md @@ -0,0 +1,11 @@ +# @golevelup/nestjs-graphql-request + +

+version +downloads +license +

+ +## Description + +This library provides the `GraphQLRequestModule` which makes it easy to initialize an instance of `GraphQLClient` for use in Depdendency Injection. This can be combined with automatic codegen for type safe access to third party GQL APIs from your Nest services diff --git a/packages/graphql-request/package-lock.json b/packages/graphql-request/package-lock.json new file mode 100644 index 000000000..302ab27d6 --- /dev/null +++ b/packages/graphql-request/package-lock.json @@ -0,0 +1,384 @@ +{ + "name": "@golevelup/nestjs-graphql-request", + "version": "0.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@nestjs/common": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-5.6.2.tgz", + "integrity": "sha512-LJkG60HXtOL0/8MgdITMUEMF9CCMa3gtmxcnxfxvqZN/cFGEFZ5QzMWbEdcP5N+kUJY2BL8gENdmPGyqBNJm0A==", + "requires": { + "axios": "0.18.0", + "cli-color": "1.2.0", + "deprecate": "1.0.0", + "multer": "1.3.0", + "uuid": "3.3.2" + } + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "append-field": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/append-field/-/append-field-0.1.0.tgz", + "integrity": "sha1-bdxY+gg8e8VF08WZWygwzCNm1Eo=" + }, + "axios": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.18.0.tgz", + "integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=", + "requires": { + "follow-redirects": "1.6.1", + "is-buffer": "1.1.6" + } + }, + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" + }, + "busboy": { + "version": "0.2.14", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz", + "integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=", + "requires": { + "dicer": "0.2.5", + "readable-stream": "1.1.14" + } + }, + "cli-color": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-1.2.0.tgz", + "integrity": "sha1-OlrnT9drYmevZm5p4q+70B3vNNE=", + "requires": { + "ansi-regex": "2.1.1", + "d": "1.0.0", + "es5-ext": "0.10.47", + "es6-iterator": "2.0.3", + "memoizee": "0.4.14", + "timers-ext": "0.1.7" + } + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "1.1.1", + "inherits": "2.0.3", + "readable-stream": "2.3.6", + "typedarray": "0.0.6" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "2.0.0", + "safe-buffer": "5.1.2", + "string_decoder": "1.1.1", + "util-deprecate": "1.0.2" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "5.1.2" + } + } + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "d": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", + "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", + "requires": { + "es5-ext": "0.10.47" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "deprecate": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/deprecate/-/deprecate-1.0.0.tgz", + "integrity": "sha1-ZhSQ7SQokWpsiIPYg05WRvTkpKg=" + }, + "dicer": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz", + "integrity": "sha1-WZbAhrszIYyBLAkL3cCc0S+stw8=", + "requires": { + "readable-stream": "1.1.14", + "streamsearch": "0.1.2" + } + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "es5-ext": { + "version": "0.10.47", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.47.tgz", + "integrity": "sha512-/1TItLfj+TTfWoeRcDn/0FbGV6SNo4R+On2GGVucPU/j3BWnXE2Co8h8CTo4Tu34gFJtnmwS9xiScKs4EjZhdw==", + "requires": { + "es6-iterator": "2.0.3", + "es6-symbol": "3.1.1", + "next-tick": "1.0.0" + } + }, + "es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.47", + "es6-symbol": "3.1.1" + } + }, + "es6-symbol": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", + "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.47" + } + }, + "es6-weak-map": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", + "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.47", + "es6-iterator": "2.0.3", + "es6-symbol": "3.1.1" + } + }, + "event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.47" + } + }, + "follow-redirects": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.6.1.tgz", + "integrity": "sha512-t2JCjbzxQpWvbhts3l6SH1DKzSrx8a+SsaVf4h6bG4kOXUuPYS/kg2Lr4gQSb7eemaHqJkOThF1BGyjlUkO1GQ==", + "requires": { + "debug": "3.1.0" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=" + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, + "lru-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", + "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=", + "requires": { + "es5-ext": "0.10.47" + } + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "memoizee": { + "version": "0.4.14", + "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.14.tgz", + "integrity": "sha512-/SWFvWegAIYAO4NQMpcX+gcra0yEZu4OntmUdrBaWrJncxOqAziGFlHxc7yjKVK2uu3lpPW27P27wkR82wA8mg==", + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.47", + "es6-weak-map": "2.0.2", + "event-emitter": "0.3.5", + "is-promise": "2.1.0", + "lru-queue": "0.1.0", + "next-tick": "1.0.0", + "timers-ext": "0.1.7" + } + }, + "mime-db": { + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", + "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==" + }, + "mime-types": { + "version": "2.1.21", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", + "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "requires": { + "mime-db": "1.37.0" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "multer": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.3.0.tgz", + "integrity": "sha1-CSsmcPaEb6SRSWXvyM+Uwg/sbNI=", + "requires": { + "append-field": "0.1.0", + "busboy": "0.2.14", + "concat-stream": "1.6.2", + "mkdirp": "0.5.1", + "object-assign": "3.0.0", + "on-finished": "2.3.0", + "type-is": "1.6.16", + "xtend": "4.0.1" + } + }, + "next-tick": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", + "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=" + }, + "object-assign": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", + "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "streamsearch": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", + "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=" + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + }, + "timers-ext": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz", + "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==", + "requires": { + "es5-ext": "0.10.47", + "next-tick": "1.0.0" + } + }, + "type-is": { + "version": "1.6.16", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", + "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "2.1.21" + } + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + } + } +} diff --git a/packages/graphql-request/package.json b/packages/graphql-request/package.json new file mode 100644 index 000000000..93a431413 --- /dev/null +++ b/packages/graphql-request/package.json @@ -0,0 +1,60 @@ +{ + "name": "@golevelup/nestjs-graphql-request", + "version": "0.0.1", + "description": "Badass utilities for integrating graphql-request and NestJS", + "author": "Jesse Carter ", + "homepage": "https://github.com/golevelup/nestjs#readme", + "license": "MIT", + "keywords": [ + "NestJS", + "graphql-request", + "sdk", + "codegen", + "graphql", + "gql" + ], + "main": "lib/index.js", + "typings": "lib/index.d.ts", + "directories": { + "lib": "lib", + "test": "__tests__" + }, + "files": [ + "lib" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/golevelup/nestjs.git" + }, + "scripts": { + "build": "tsc --build tsconfig.build.json", + "build:watch": "tsc --build tsconfig.build.json --watch", + "test": "jest" + }, + "bugs": { + "url": "https://github.com/golevelup/nestjs/issues" + }, + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@golevelup/nestjs-discovery": "^2.2.4-rc.0", + "@golevelup/nestjs-modules": "^0.3.2-rc.0", + "graphql-request": "^1.8.2" + }, + "jest": { + "moduleFileExtensions": [ + "js", + "json", + "ts" + ], + "rootDir": "src", + "testRegex": ".spec.ts$", + "transform": { + "^.+\\.ts$": "ts-jest" + }, + "coverageDirectory": "../coverage", + "testEnvironment": "node" + }, + "gitHead": "6f97aab8ce9d65dc074750a3ee467ec5ff3b9908" +} diff --git a/packages/graphql-request/src/graphql-request.constants.ts b/packages/graphql-request/src/graphql-request.constants.ts new file mode 100644 index 000000000..469150118 --- /dev/null +++ b/packages/graphql-request/src/graphql-request.constants.ts @@ -0,0 +1,2 @@ +export const GraphQLClientConfigInject = Symbol('GraphQLClientConfigInject'); +export const GraphQLClientInject = Symbol('GraphQLClientInject'); diff --git a/packages/graphql-request/src/graphql-request.module.ts b/packages/graphql-request/src/graphql-request.module.ts new file mode 100644 index 000000000..d3180d523 --- /dev/null +++ b/packages/graphql-request/src/graphql-request.module.ts @@ -0,0 +1,33 @@ +import { createConfigurableDynamicRootModule } from '@golevelup/nestjs-modules'; +import { Module } from '@nestjs/common'; +import { GraphQLClient } from 'graphql-request'; +import { + GraphQLClientConfigInject, + GraphQLClientInject, +} from './graphql-request.constants'; + +type GraphQLClientConstructorParams = ConstructorParameters< + typeof GraphQLClient +>; + +interface GraphQLRequestModuleConfig { + endpoint: GraphQLClientConstructorParams[0]; + options?: GraphQLClientConstructorParams[1]; +} + +@Module({}) +export class GraphQLRequestModule extends createConfigurableDynamicRootModule< + GraphQLRequestModule, + GraphQLRequestModuleConfig +>(GraphQLClientConfigInject, { + providers: [ + { + provide: GraphQLClientInject, + useFactory: ({ endpoint, options }: GraphQLRequestModuleConfig) => { + return new GraphQLClient(endpoint, options); + }, + inject: [GraphQLClientConfigInject], + }, + ], + exports: [GraphQLClientInject], +}) {} diff --git a/packages/graphql-request/src/index.ts b/packages/graphql-request/src/index.ts new file mode 100644 index 000000000..160fd5a84 --- /dev/null +++ b/packages/graphql-request/src/index.ts @@ -0,0 +1 @@ +export * from './graphql-request.module'; diff --git a/packages/graphql-request/src/test/graphql-request.module.spec.ts b/packages/graphql-request/src/test/graphql-request.module.spec.ts new file mode 100644 index 000000000..2dd3be739 --- /dev/null +++ b/packages/graphql-request/src/test/graphql-request.module.spec.ts @@ -0,0 +1,27 @@ +import { INestApplication } from '@nestjs/common'; +import { Test } from '@nestjs/testing'; +import { GraphQLClient } from 'graphql-request'; +import { GraphQLRequestModule } from '../graphql-request.module'; +import { GraphQLClientInject } from './../graphql-request.constants'; + +describe('GraphQL Request Module', () => { + let app: INestApplication; + + beforeEach(async () => { + const moduleFixture = await Test.createTestingModule({ + imports: [ + GraphQLRequestModule.forRoot(GraphQLRequestModule, { + endpoint: 'some-graphql-endpoint', + }), + ], + }).compile(); + + app = moduleFixture.createNestApplication(); + await app.init(); + }); + + it('provides a graphql client', () => { + const client = app.get(GraphQLClientInject); + expect(client).toBeInstanceOf(GraphQLClient); + }); +}); diff --git a/packages/graphql-request/tsconfig.build.json b/packages/graphql-request/tsconfig.build.json new file mode 100644 index 000000000..346c5b9d9 --- /dev/null +++ b/packages/graphql-request/tsconfig.build.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "exclude": ["./src/**/*.spec.ts", "node_modules"] +} diff --git a/packages/graphql-request/tsconfig.json b/packages/graphql-request/tsconfig.json new file mode 100644 index 000000000..e748f35c6 --- /dev/null +++ b/packages/graphql-request/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./lib", + "rootDir": "./src" + }, + "include": ["./src"], + "references": [{ "path": "../discovery" }, { "path": "../modules" }] +} diff --git a/packages/hasura/src/hasura.module.ts b/packages/hasura/src/hasura.module.ts index b29c50637..d10090f8e 100644 --- a/packages/hasura/src/hasura.module.ts +++ b/packages/hasura/src/hasura.module.ts @@ -18,6 +18,7 @@ import { HasuraEventHandlerConfig, HasuraModuleConfig, } from './hasura.interfaces'; + @Module({ imports: [DiscoveryModule], })