├── .gitignore ├── LICENSE ├── README.md ├── package.json ├── pnpm-lock.yaml ├── src ├── graphiql.ts └── index.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | /public/sitemap.xml 18 | /dist 19 | 20 | # misc 21 | .DS_Store 22 | *.pem 23 | 24 | # debug 25 | npm-debug.log* 26 | yarn-debug.log* 27 | yarn-error.log* 28 | 29 | # local env files 30 | .env.local 31 | .env.development.local 32 | .env.test.local 33 | .env.production.local 34 | 35 | # vercel 36 | .vercel 37 | .pnpm-debug.log 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # next-graphql-server 2 | 3 | `next-graphql-server` is an easy to use Next.js library for creating performant GraphQL endpoints on top of [Next.js API Routes](https://nextjs.org/docs/api-routes/introduction). 4 | 5 | Start building GraphQL servers with Next.js. 6 | 7 | ## Features 8 | 9 | * built using [Envelop](https://www.envelop.dev) and [Helix](https://graphql-helix.vercel.app) - stackable and easy to extend architecture 10 | * supports Vercel Edge functions 11 | 12 | ## Getting Started 13 | 14 | Create a Next.js project: 15 | 16 | ``` 17 | pnpm create next-app --typescript 18 | ``` 19 | 20 | Add `next-graphql-server` as a dependency to your Next.js project: 21 | 22 | ``` 23 | pnpm add next-graphql-server 24 | ``` 25 | 26 | **Note**: `pnpm` is preferred, but you can also use `npm` or `yarn` 27 | 28 | ``` 29 | npm install next-graphql-server 30 | ``` 31 | 32 | ``` 33 | yarn add next-graphql-server 34 | ``` 35 | 36 | ## Usage 37 | 38 | `next-graphql-server` uses [Next.js API Routes](https://nextjs.org/docs/api-routes/introduction). Create the `pages/api/graphql.ts` with the following content: 39 | 40 | **Note**: The file in `pages/api` must be named `graphql` 41 | 42 | ### with `graphql` 43 | 44 | Add `graphql` 45 | 46 | ``` 47 | pnpm add graphql 48 | ``` 49 | 50 | ```ts 51 | import { createGraphQLHandler } from "next-graphql-server"; 52 | import { 53 | GraphQLObjectType, 54 | GraphQLSchema, 55 | GraphQLString, 56 | } from "graphql"; 57 | 58 | const schema = new GraphQLSchema({ 59 | query: new GraphQLObjectType({ 60 | name: "Query", 61 | fields: () => ({ 62 | hello: { 63 | type: GraphQLString, 64 | resolve: () => "world", 65 | }, 66 | }), 67 | }), 68 | }); 69 | 70 | const handler = createGraphQLHandler(schema); 71 | export default handler; 72 | ``` 73 | 74 | ### with `@graphql-tools` 75 | 76 | Add `@graphql-tools/schema` 77 | 78 | ``` 79 | pnpm add @graphql-tools/schema 80 | ``` 81 | 82 | In `pages/api/graphql.ts` define your handler as shown below: 83 | 84 | ```ts 85 | import { createGraphQLHandler } from "next-graphql-server"; 86 | import { makeExecutableSchema } from "@graphql-tools/schema"; 87 | 88 | export const schema = makeExecutableSchema({ 89 | typeDefs: /* GraphQL */ ` 90 | type Query { 91 | hello: String! 92 | } 93 | `, 94 | resolvers: { 95 | Query: { 96 | hello: () => 'World', 97 | }, 98 | }, 99 | }); 100 | 101 | const handler = createGraphQLHandler(schema); 102 | export default handler; 103 | ``` 104 | 105 | ### with Pothos -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "next-graphql-server", 3 | "version": "0.11.0", 4 | "description": "Build GraphQL Servers with Next.js", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.js", 7 | "author": "Zaiste", 8 | "license": "Apache 2.0", 9 | "scripts": { 10 | "watch": "tsc -w" 11 | }, 12 | "dependencies": { 13 | "@envelop/core": "^3.0.4", 14 | "@envelop/generic-auth": "^5.0.4", 15 | "@graphql-tools/schema": "^9.0.12", 16 | "graphql": "16.6.0" 17 | }, 18 | "devDependencies": { 19 | "@types/node": "^18.11.17", 20 | "clean-publish": "^4.0.2", 21 | "next": "^13.1.1", 22 | "typescript": "4.9.4" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /pnpm-lock.yaml: -------------------------------------------------------------------------------- 1 | lockfileVersion: 5.4 2 | 3 | specifiers: 4 | '@envelop/core': ^3.0.4 5 | '@envelop/generic-auth': ^5.0.4 6 | '@graphql-tools/schema': ^9.0.12 7 | '@types/node': ^18.11.17 8 | clean-publish: ^4.0.2 9 | graphql: 16.6.0 10 | next: ^13.1.1 11 | typescript: 4.9.4 12 | 13 | dependencies: 14 | '@envelop/core': 3.0.4 15 | '@envelop/generic-auth': 5.0.4_a6sekiasy2tqr6d5gj7n2wtjli 16 | '@graphql-tools/schema': 9.0.12_graphql@16.6.0 17 | graphql: 16.6.0 18 | 19 | devDependencies: 20 | '@types/node': 18.11.17 21 | clean-publish: 4.0.2 22 | next: 13.1.1 23 | typescript: 4.9.4 24 | 25 | packages: 26 | 27 | /@envelop/core/3.0.4: 28 | resolution: {integrity: sha512-AybIZxQsDlFQTWHy6YtX/MSQPVuw+eOFtTW90JsHn6EbmcQnD6N3edQfSiTGjggPRHLoC0+0cuYXp2Ly2r3vrQ==} 29 | dependencies: 30 | '@envelop/types': 3.0.1 31 | tslib: 2.4.0 32 | dev: false 33 | 34 | /@envelop/extended-validation/2.0.4_a6sekiasy2tqr6d5gj7n2wtjli: 35 | resolution: {integrity: sha512-23B6VgizjItYehAGB4ZDT9VVmYCHxYVnbJ4XPvlT5R0KSEmTAzoCHTJ5Y+hnQ/lP3wk5OgZZI5HTDSi8CcSNug==} 36 | peerDependencies: 37 | '@envelop/core': ^3.0.4 38 | graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 39 | dependencies: 40 | '@envelop/core': 3.0.4 41 | '@graphql-tools/utils': 8.13.1_graphql@16.6.0 42 | graphql: 16.6.0 43 | tslib: 2.4.1 44 | dev: false 45 | 46 | /@envelop/generic-auth/5.0.4_a6sekiasy2tqr6d5gj7n2wtjli: 47 | resolution: {integrity: sha512-D6cSPjNlVV6lJUoTJZVkzjN/F9/nFLvYuotjcZQHue7tCBxegFDUrXf30AfJj3g/RMLZC7U2O6kWvZx5qzTK+w==} 48 | peerDependencies: 49 | '@envelop/core': ^3.0.4 50 | graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 51 | dependencies: 52 | '@envelop/core': 3.0.4 53 | '@envelop/extended-validation': 2.0.4_a6sekiasy2tqr6d5gj7n2wtjli 54 | graphql: 16.6.0 55 | tslib: 2.4.1 56 | dev: false 57 | 58 | /@envelop/types/3.0.1: 59 | resolution: {integrity: sha512-Ok62K1K+rlS+wQw77k8Pis8+1/h7+/9Wk5Fgcc2U6M5haEWsLFAHcHsk8rYlnJdEUl2Y3yJcCSOYbt1dyTaU5w==} 60 | dependencies: 61 | tslib: 2.4.0 62 | dev: false 63 | 64 | /@graphql-tools/merge/8.3.14_graphql@16.6.0: 65 | resolution: {integrity: sha512-zV0MU1DnxJLIB0wpL4N3u21agEiYFsjm6DI130jqHpwF0pR9HkF+Ni65BNfts4zQelP0GjkHltG+opaozAJ1NA==} 66 | peerDependencies: 67 | graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 68 | dependencies: 69 | '@graphql-tools/utils': 9.1.3_graphql@16.6.0 70 | graphql: 16.6.0 71 | tslib: 2.4.1 72 | dev: false 73 | 74 | /@graphql-tools/schema/9.0.12_graphql@16.6.0: 75 | resolution: {integrity: sha512-DmezcEltQai0V1y96nwm0Kg11FDS/INEFekD4nnVgzBqawvznWqK6D6bujn+cw6kivoIr3Uq//QmU/hBlBzUlQ==} 76 | peerDependencies: 77 | graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 78 | dependencies: 79 | '@graphql-tools/merge': 8.3.14_graphql@16.6.0 80 | '@graphql-tools/utils': 9.1.3_graphql@16.6.0 81 | graphql: 16.6.0 82 | tslib: 2.4.1 83 | value-or-promise: 1.0.11 84 | dev: false 85 | 86 | /@graphql-tools/utils/8.13.1_graphql@16.6.0: 87 | resolution: {integrity: sha512-qIh9yYpdUFmctVqovwMdheVNJqFh+DQNWIhX87FJStfXYnmweBUDATok9fWPleKeFwxnW8IapKmY8m8toJEkAw==} 88 | peerDependencies: 89 | graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 90 | dependencies: 91 | graphql: 16.6.0 92 | tslib: 2.4.1 93 | dev: false 94 | 95 | /@graphql-tools/utils/9.1.3_graphql@16.6.0: 96 | resolution: {integrity: sha512-bbJyKhs6awp1/OmP+WKA1GOyu9UbgZGkhIj5srmiMGLHohEOKMjW784Sk0BZil1w2x95UPu0WHw6/d/HVCACCg==} 97 | peerDependencies: 98 | graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 99 | dependencies: 100 | graphql: 16.6.0 101 | tslib: 2.4.1 102 | dev: false 103 | 104 | /@next/env/13.1.1: 105 | resolution: {integrity: sha512-vFMyXtPjSAiOXOywMojxfKIqE3VWN5RCAx+tT3AS3pcKjMLFTCJFUWsKv8hC+87Z1F4W3r68qTwDFZIFmd5Xkw==} 106 | dev: true 107 | 108 | /@next/swc-android-arm-eabi/13.1.1: 109 | resolution: {integrity: sha512-qnFCx1kT3JTWhWve4VkeWuZiyjG0b5T6J2iWuin74lORCupdrNukxkq9Pm+Z7PsatxuwVJMhjUoYz7H4cWzx2A==} 110 | engines: {node: '>= 10'} 111 | cpu: [arm] 112 | os: [android] 113 | requiresBuild: true 114 | dev: true 115 | optional: true 116 | 117 | /@next/swc-android-arm64/13.1.1: 118 | resolution: {integrity: sha512-eCiZhTzjySubNqUnNkQCjU3Fh+ep3C6b5DCM5FKzsTH/3Gr/4Y7EiaPZKILbvnXmhWtKPIdcY6Zjx51t4VeTfA==} 119 | engines: {node: '>= 10'} 120 | cpu: [arm64] 121 | os: [android] 122 | requiresBuild: true 123 | dev: true 124 | optional: true 125 | 126 | /@next/swc-darwin-arm64/13.1.1: 127 | resolution: {integrity: sha512-9zRJSSIwER5tu9ADDkPw5rIZ+Np44HTXpYMr0rkM656IvssowPxmhK0rTreC1gpUCYwFsRbxarUJnJsTWiutPg==} 128 | engines: {node: '>= 10'} 129 | cpu: [arm64] 130 | os: [darwin] 131 | requiresBuild: true 132 | dev: true 133 | optional: true 134 | 135 | /@next/swc-darwin-x64/13.1.1: 136 | resolution: {integrity: sha512-qWr9qEn5nrnlhB0rtjSdR00RRZEtxg4EGvicIipqZWEyayPxhUu6NwKiG8wZiYZCLfJ5KWr66PGSNeDMGlNaiA==} 137 | engines: {node: '>= 10'} 138 | cpu: [x64] 139 | os: [darwin] 140 | requiresBuild: true 141 | dev: true 142 | optional: true 143 | 144 | /@next/swc-freebsd-x64/13.1.1: 145 | resolution: {integrity: sha512-UwP4w/NcQ7V/VJEj3tGVszgb4pyUCt3lzJfUhjDMUmQbzG9LDvgiZgAGMYH6L21MoyAATJQPDGiAMWAPKsmumA==} 146 | engines: {node: '>= 10'} 147 | cpu: [x64] 148 | os: [freebsd] 149 | requiresBuild: true 150 | dev: true 151 | optional: true 152 | 153 | /@next/swc-linux-arm-gnueabihf/13.1.1: 154 | resolution: {integrity: sha512-CnsxmKHco9sosBs1XcvCXP845Db+Wx1G0qouV5+Gr+HT/ZlDYEWKoHVDgnJXLVEQzq4FmHddBNGbXvgqM1Gfkg==} 155 | engines: {node: '>= 10'} 156 | cpu: [arm] 157 | os: [linux] 158 | requiresBuild: true 159 | dev: true 160 | optional: true 161 | 162 | /@next/swc-linux-arm64-gnu/13.1.1: 163 | resolution: {integrity: sha512-JfDq1eri5Dif+VDpTkONRd083780nsMCOKoFG87wA0sa4xL8LGcXIBAkUGIC1uVy9SMsr2scA9CySLD/i+Oqiw==} 164 | engines: {node: '>= 10'} 165 | cpu: [arm64] 166 | os: [linux] 167 | requiresBuild: true 168 | dev: true 169 | optional: true 170 | 171 | /@next/swc-linux-arm64-musl/13.1.1: 172 | resolution: {integrity: sha512-GA67ZbDq2AW0CY07zzGt07M5b5Yaq5qUpFIoW3UFfjOPgb0Sqf3DAW7GtFMK1sF4ROHsRDMGQ9rnT0VM2dVfKA==} 173 | engines: {node: '>= 10'} 174 | cpu: [arm64] 175 | os: [linux] 176 | requiresBuild: true 177 | dev: true 178 | optional: true 179 | 180 | /@next/swc-linux-x64-gnu/13.1.1: 181 | resolution: {integrity: sha512-nnjuBrbzvqaOJaV+XgT8/+lmXrSCOt1YYZn/irbDb2fR2QprL6Q7WJNgwsZNxiLSfLdv+2RJGGegBx9sLBEzGA==} 182 | engines: {node: '>= 10'} 183 | cpu: [x64] 184 | os: [linux] 185 | requiresBuild: true 186 | dev: true 187 | optional: true 188 | 189 | /@next/swc-linux-x64-musl/13.1.1: 190 | resolution: {integrity: sha512-CM9xnAQNIZ8zf/igbIT/i3xWbQZYaF397H+JroF5VMOCUleElaMdQLL5riJml8wUfPoN3dtfn2s4peSr3azz/g==} 191 | engines: {node: '>= 10'} 192 | cpu: [x64] 193 | os: [linux] 194 | requiresBuild: true 195 | dev: true 196 | optional: true 197 | 198 | /@next/swc-win32-arm64-msvc/13.1.1: 199 | resolution: {integrity: sha512-pzUHOGrbgfGgPlOMx9xk3QdPJoRPU+om84hqVoe6u+E0RdwOG0Ho/2UxCgDqmvpUrMab1Deltlt6RqcXFpnigQ==} 200 | engines: {node: '>= 10'} 201 | cpu: [arm64] 202 | os: [win32] 203 | requiresBuild: true 204 | dev: true 205 | optional: true 206 | 207 | /@next/swc-win32-ia32-msvc/13.1.1: 208 | resolution: {integrity: sha512-WeX8kVS46aobM9a7Xr/kEPcrTyiwJqQv/tbw6nhJ4fH9xNZ+cEcyPoQkwPo570dCOLz3Zo9S2q0E6lJ/EAUOBg==} 209 | engines: {node: '>= 10'} 210 | cpu: [ia32] 211 | os: [win32] 212 | requiresBuild: true 213 | dev: true 214 | optional: true 215 | 216 | /@next/swc-win32-x64-msvc/13.1.1: 217 | resolution: {integrity: sha512-mVF0/3/5QAc5EGVnb8ll31nNvf3BWpPY4pBb84tk+BfQglWLqc5AC9q1Ht/YMWiEgs8ALNKEQ3GQnbY0bJF2Gg==} 218 | engines: {node: '>= 10'} 219 | cpu: [x64] 220 | os: [win32] 221 | requiresBuild: true 222 | dev: true 223 | optional: true 224 | 225 | /@nodelib/fs.scandir/2.1.5: 226 | resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} 227 | engines: {node: '>= 8'} 228 | dependencies: 229 | '@nodelib/fs.stat': 2.0.5 230 | run-parallel: 1.2.0 231 | dev: true 232 | 233 | /@nodelib/fs.stat/2.0.5: 234 | resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} 235 | engines: {node: '>= 8'} 236 | dev: true 237 | 238 | /@nodelib/fs.walk/1.2.8: 239 | resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} 240 | engines: {node: '>= 8'} 241 | dependencies: 242 | '@nodelib/fs.scandir': 2.1.5 243 | fastq: 1.14.0 244 | dev: true 245 | 246 | /@swc/helpers/0.4.14: 247 | resolution: {integrity: sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==} 248 | dependencies: 249 | tslib: 2.4.1 250 | dev: true 251 | 252 | /@types/node/18.11.17: 253 | resolution: {integrity: sha512-HJSUJmni4BeDHhfzn6nF0sVmd1SMezP7/4F0Lq+aXzmp2xm9O7WXrUtHW/CHlYVtZUbByEvWidHqRtcJXGF2Ng==} 254 | dev: true 255 | 256 | /braces/3.0.2: 257 | resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} 258 | engines: {node: '>=8'} 259 | dependencies: 260 | fill-range: 7.0.1 261 | dev: true 262 | 263 | /caniuse-lite/1.0.30001441: 264 | resolution: {integrity: sha512-OyxRR4Vof59I3yGWXws6i908EtGbMzVUi3ganaZQHmydk1iwDhRnvaPG2WaR0KcqrDFKrxVZHULT396LEPhXfg==} 265 | dev: true 266 | 267 | /clean-publish/4.0.2: 268 | resolution: {integrity: sha512-WLg3deN5jTs6W3JjioTywlfmFMvOFTTwkhUQ6QJ/6b4Um7pqOM5g/NivYnUFTasi3j3BARAP6HIKxGWlWPJ8hw==} 269 | engines: {node: '>= 16.0.0'} 270 | hasBin: true 271 | dependencies: 272 | cross-spawn: 7.0.3 273 | fast-glob: 3.2.12 274 | lilconfig: 2.0.6 275 | micromatch: 4.0.5 276 | dev: true 277 | 278 | /client-only/0.0.1: 279 | resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==} 280 | dev: true 281 | 282 | /cross-spawn/7.0.3: 283 | resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} 284 | engines: {node: '>= 8'} 285 | dependencies: 286 | path-key: 3.1.1 287 | shebang-command: 2.0.0 288 | which: 2.0.2 289 | dev: true 290 | 291 | /fast-glob/3.2.12: 292 | resolution: {integrity: sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==} 293 | engines: {node: '>=8.6.0'} 294 | dependencies: 295 | '@nodelib/fs.stat': 2.0.5 296 | '@nodelib/fs.walk': 1.2.8 297 | glob-parent: 5.1.2 298 | merge2: 1.4.1 299 | micromatch: 4.0.5 300 | dev: true 301 | 302 | /fastq/1.14.0: 303 | resolution: {integrity: sha512-eR2D+V9/ExcbF9ls441yIuN6TI2ED1Y2ZcA5BmMtJsOkWOFRJQ0Jt0g1UwqXJJVAb+V+umH5Dfr8oh4EVP7VVg==} 304 | dependencies: 305 | reusify: 1.0.4 306 | dev: true 307 | 308 | /fill-range/7.0.1: 309 | resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} 310 | engines: {node: '>=8'} 311 | dependencies: 312 | to-regex-range: 5.0.1 313 | dev: true 314 | 315 | /glob-parent/5.1.2: 316 | resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} 317 | engines: {node: '>= 6'} 318 | dependencies: 319 | is-glob: 4.0.3 320 | dev: true 321 | 322 | /graphql/16.6.0: 323 | resolution: {integrity: sha512-KPIBPDlW7NxrbT/eh4qPXz5FiFdL5UbaA0XUNz2Rp3Z3hqBSkbj0GVjwFDztsWVauZUWsbKHgMg++sk8UX0bkw==} 324 | engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} 325 | dev: false 326 | 327 | /is-extglob/2.1.1: 328 | resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} 329 | engines: {node: '>=0.10.0'} 330 | dev: true 331 | 332 | /is-glob/4.0.3: 333 | resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} 334 | engines: {node: '>=0.10.0'} 335 | dependencies: 336 | is-extglob: 2.1.1 337 | dev: true 338 | 339 | /is-number/7.0.0: 340 | resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} 341 | engines: {node: '>=0.12.0'} 342 | dev: true 343 | 344 | /isexe/2.0.0: 345 | resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} 346 | dev: true 347 | 348 | /lilconfig/2.0.6: 349 | resolution: {integrity: sha512-9JROoBW7pobfsx+Sq2JsASvCo6Pfo6WWoUW79HuB1BCoBXD4PLWJPqDF6fNj67pqBYTbAHkE57M1kS/+L1neOg==} 350 | engines: {node: '>=10'} 351 | dev: true 352 | 353 | /merge2/1.4.1: 354 | resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} 355 | engines: {node: '>= 8'} 356 | dev: true 357 | 358 | /micromatch/4.0.5: 359 | resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} 360 | engines: {node: '>=8.6'} 361 | dependencies: 362 | braces: 3.0.2 363 | picomatch: 2.3.1 364 | dev: true 365 | 366 | /nanoid/3.3.4: 367 | resolution: {integrity: sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==} 368 | engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} 369 | hasBin: true 370 | dev: true 371 | 372 | /next/13.1.1: 373 | resolution: {integrity: sha512-R5eBAaIa3X7LJeYvv1bMdGnAVF4fVToEjim7MkflceFPuANY3YyvFxXee/A+acrSYwYPvOvf7f6v/BM/48ea5w==} 374 | engines: {node: '>=14.6.0'} 375 | hasBin: true 376 | peerDependencies: 377 | fibers: '>= 3.1.0' 378 | node-sass: ^6.0.0 || ^7.0.0 379 | react: ^18.2.0 380 | react-dom: ^18.2.0 381 | sass: ^1.3.0 382 | peerDependenciesMeta: 383 | fibers: 384 | optional: true 385 | node-sass: 386 | optional: true 387 | sass: 388 | optional: true 389 | dependencies: 390 | '@next/env': 13.1.1 391 | '@swc/helpers': 0.4.14 392 | caniuse-lite: 1.0.30001441 393 | postcss: 8.4.14 394 | styled-jsx: 5.1.1 395 | optionalDependencies: 396 | '@next/swc-android-arm-eabi': 13.1.1 397 | '@next/swc-android-arm64': 13.1.1 398 | '@next/swc-darwin-arm64': 13.1.1 399 | '@next/swc-darwin-x64': 13.1.1 400 | '@next/swc-freebsd-x64': 13.1.1 401 | '@next/swc-linux-arm-gnueabihf': 13.1.1 402 | '@next/swc-linux-arm64-gnu': 13.1.1 403 | '@next/swc-linux-arm64-musl': 13.1.1 404 | '@next/swc-linux-x64-gnu': 13.1.1 405 | '@next/swc-linux-x64-musl': 13.1.1 406 | '@next/swc-win32-arm64-msvc': 13.1.1 407 | '@next/swc-win32-ia32-msvc': 13.1.1 408 | '@next/swc-win32-x64-msvc': 13.1.1 409 | transitivePeerDependencies: 410 | - '@babel/core' 411 | - babel-plugin-macros 412 | dev: true 413 | 414 | /path-key/3.1.1: 415 | resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} 416 | engines: {node: '>=8'} 417 | dev: true 418 | 419 | /picocolors/1.0.0: 420 | resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} 421 | dev: true 422 | 423 | /picomatch/2.3.1: 424 | resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} 425 | engines: {node: '>=8.6'} 426 | dev: true 427 | 428 | /postcss/8.4.14: 429 | resolution: {integrity: sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==} 430 | engines: {node: ^10 || ^12 || >=14} 431 | dependencies: 432 | nanoid: 3.3.4 433 | picocolors: 1.0.0 434 | source-map-js: 1.0.2 435 | dev: true 436 | 437 | /queue-microtask/1.2.3: 438 | resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} 439 | dev: true 440 | 441 | /reusify/1.0.4: 442 | resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} 443 | engines: {iojs: '>=1.0.0', node: '>=0.10.0'} 444 | dev: true 445 | 446 | /run-parallel/1.2.0: 447 | resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} 448 | dependencies: 449 | queue-microtask: 1.2.3 450 | dev: true 451 | 452 | /shebang-command/2.0.0: 453 | resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} 454 | engines: {node: '>=8'} 455 | dependencies: 456 | shebang-regex: 3.0.0 457 | dev: true 458 | 459 | /shebang-regex/3.0.0: 460 | resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} 461 | engines: {node: '>=8'} 462 | dev: true 463 | 464 | /source-map-js/1.0.2: 465 | resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} 466 | engines: {node: '>=0.10.0'} 467 | dev: true 468 | 469 | /styled-jsx/5.1.1: 470 | resolution: {integrity: sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==} 471 | engines: {node: '>= 12.0.0'} 472 | peerDependencies: 473 | '@babel/core': '*' 474 | babel-plugin-macros: '*' 475 | react: '>= 16.8.0 || 17.x.x || ^18.0.0-0' 476 | peerDependenciesMeta: 477 | '@babel/core': 478 | optional: true 479 | babel-plugin-macros: 480 | optional: true 481 | dependencies: 482 | client-only: 0.0.1 483 | dev: true 484 | 485 | /to-regex-range/5.0.1: 486 | resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} 487 | engines: {node: '>=8.0'} 488 | dependencies: 489 | is-number: 7.0.0 490 | dev: true 491 | 492 | /tslib/2.4.0: 493 | resolution: {integrity: sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==} 494 | dev: false 495 | 496 | /tslib/2.4.1: 497 | resolution: {integrity: sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==} 498 | 499 | /typescript/4.9.4: 500 | resolution: {integrity: sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==} 501 | engines: {node: '>=4.2.0'} 502 | hasBin: true 503 | dev: true 504 | 505 | /value-or-promise/1.0.11: 506 | resolution: {integrity: sha512-41BrgH+dIbCFXClcSapVs5M6GkENd3gQOJpEfPDNa71LsUGMXDL0jMWpI/Rh7WhX+Aalfz2TTS3Zt5pUsbnhLg==} 507 | engines: {node: '>=12'} 508 | dev: false 509 | 510 | /which/2.0.2: 511 | resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} 512 | engines: {node: '>= 8'} 513 | hasBin: true 514 | dependencies: 515 | isexe: 2.0.0 516 | dev: true 517 | 518 | publishDirectory: package 519 | -------------------------------------------------------------------------------- /src/graphiql.ts: -------------------------------------------------------------------------------- 1 | export const GraphiQL = (url: string) => 2 | ` 3 | 4 | 5 | 17 | 21 | 25 | 26 | 27 | 28 | 29 |
Loading...
30 | 34 | 43 | 44 | 45 | `; 46 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import type { NextApiRequest, NextApiResponse } from 'next'; 2 | 3 | import * as GraphQL from "graphql"; 4 | 5 | 6 | import { 7 | envelop, 8 | useLogger as Logger, 9 | useSchema, 10 | useEngine 11 | } from "@envelop/core"; 12 | import { useGenericAuth, GenericAuthPluginOptions } from '@envelop/generic-auth'; 13 | 14 | import { GraphiQL } from './graphiql'; 15 | 16 | interface Options { 17 | useLogger?: boolean 18 | useTiming?: boolean 19 | useImmediateIntrospection?: boolean 20 | useAuth?: GenericAuthPluginOptions 21 | 22 | endpoint?: string 23 | edge?: boolean 24 | context?: Function 25 | } 26 | 27 | export const createGraphQLHandler = (schema: GraphQL.GraphQLSchema, { 28 | useLogger, 29 | useAuth, 30 | endpoint = '/api/graphql', 31 | edge = false, 32 | context = () => { }, 33 | }: Options = {}) => { 34 | 35 | const plugins = [ 36 | useEngine(GraphQL), 37 | useSchema(schema), 38 | ...(useLogger ? [Logger()] : []), 39 | ...(useAuth ? [useGenericAuth(useAuth)] : []), 40 | ]; 41 | 42 | const getEnveloped = envelop({ plugins }); 43 | 44 | const handler = edge ? async (req: Request) => { 45 | if (req.method === "GET") { 46 | return new Response(GraphiQL(endpoint), { 47 | headers: { 48 | "Content-Type": "text/html" 49 | } 50 | }) 51 | } else { 52 | const { parse, validate, contextFactory, execute, schema } = getEnveloped({ req }); 53 | 54 | const _a = context; 55 | 56 | const { query, variables } = await req.json(); 57 | const document = parse(query) 58 | const validationErrors = validate(schema, document) 59 | 60 | if (validationErrors.length > 0) { 61 | return new Response(JSON.stringify({ errors: validationErrors })) 62 | } 63 | 64 | const contextValue = await contextFactory() 65 | const result = await execute({ 66 | document, 67 | schema, 68 | variableValues: variables, 69 | contextValue 70 | }) 71 | 72 | return new Response(JSON.stringify(result), { 73 | headers: { 74 | "Content-Type": "application/json" 75 | } 76 | }) 77 | } 78 | } : async (req: NextApiRequest, res: NextApiResponse) => { 79 | if (req.method === "GET") { 80 | res.writeHead(200, { 81 | "content-type": "text/html", 82 | }); 83 | res.end(GraphiQL(endpoint)); 84 | } else { 85 | const { 86 | parse, 87 | validate, 88 | contextFactory, 89 | execute, 90 | schema 91 | } = getEnveloped({ req }) 92 | 93 | const { query, variables } = req.body 94 | const document = parse(query) 95 | const validationErrors = validate(schema, document) 96 | 97 | if (validationErrors.length > 0) { 98 | return res.end(JSON.stringify({ errors: validationErrors })) 99 | } 100 | 101 | // Build the context and execute 102 | const contextValue = await contextFactory() 103 | const result = await execute({ 104 | document, 105 | schema, 106 | variableValues: variables, 107 | contextValue 108 | }) 109 | 110 | // Send the response 111 | res.end(JSON.stringify(result)) 112 | } 113 | 114 | return 115 | }; 116 | 117 | return handler; 118 | }; 119 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "target": "ES2021", 5 | "lib": ["ES2021", "DOM", "DOM.Iterable"], 6 | "module": "commonjs", 7 | "moduleResolution": "node", 8 | "declaration": true, 9 | "checkJs": false, 10 | "strict": true, 11 | "noImplicitReturns": true, 12 | "skipLibCheck": true, 13 | "allowSyntheticDefaultImports": true, 14 | "esModuleInterop": true 15 | }, 16 | "include": ["src/**/*"], 17 | "exclude": ["examples/**/*"] 18 | } 19 | --------------------------------------------------------------------------------