nitro-graphql 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/graphql/index.js +1 -0
- package/dist/graphql/server.js +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/routes/apollo-server.d.ts +2 -2
- package/dist/routes/apollo-server.js +5 -1
- package/dist/routes/graphql-yoga.d.ts +2 -2
- package/dist/routes/graphql-yoga.js +5 -1
- package/dist/routes/health.d.ts +2 -2
- package/dist/utils/client-codegen.js +1 -1
- package/dist/utils/index.js +13 -2
- package/dist/utils/type-generation.js +110 -10
- package/package.json +29 -18
- package/dist/_virtual/rolldown_runtime.js +0 -37
- package/dist/node_modules/.pnpm/@graphql-codegen_add@3.2.3_graphql@16.11.0/node_modules/@graphql-codegen/add/esm/config.js +0 -9
- package/dist/node_modules/.pnpm/@graphql-codegen_add@3.2.3_graphql@16.11.0/node_modules/@graphql-codegen/add/esm/index.js +0 -17
- package/dist/node_modules/.pnpm/@graphql-codegen_import-types-preset@3.0.1_graphql@16.11.0/node_modules/@graphql-codegen/import-types-preset/esm/index.js +0 -38
- package/dist/node_modules/.pnpm/@graphql-codegen_plugin-helpers@3.1.2_graphql@16.11.0/node_modules/@graphql-codegen/plugin-helpers/esm/federation.js +0 -22
- package/dist/node_modules/.pnpm/@graphql-codegen_plugin-helpers@3.1.2_graphql@16.11.0/node_modules/@graphql-codegen/plugin-helpers/esm/getCachedDocumentNodeFromSchema.js +0 -6
- package/dist/node_modules/.pnpm/@graphql-codegen_plugin-helpers@3.1.2_graphql@16.11.0/node_modules/@graphql-codegen/plugin-helpers/esm/helpers.js +0 -79
- package/dist/node_modules/.pnpm/@graphql-codegen_plugin-helpers@3.1.2_graphql@16.11.0/node_modules/@graphql-codegen/plugin-helpers/esm/index.js +0 -6
- package/dist/node_modules/.pnpm/@graphql-codegen_plugin-helpers@3.1.2_graphql@16.11.0/node_modules/@graphql-codegen/plugin-helpers/esm/oldVisit.js +0 -1
- package/dist/node_modules/.pnpm/@graphql-codegen_plugin-helpers@3.1.2_graphql@16.11.0/node_modules/@graphql-codegen/plugin-helpers/esm/resolve-external-module-and-fn.js +0 -7
- package/dist/node_modules/.pnpm/@graphql-codegen_plugin-helpers@3.1.2_graphql@16.11.0/node_modules/@graphql-codegen/plugin-helpers/esm/utils.js +0 -13
- package/dist/node_modules/.pnpm/camel-case@4.1.2/node_modules/camel-case/dist/index.js +0 -33
- package/dist/node_modules/.pnpm/capital-case@1.0.4/node_modules/capital-case/dist/index.js +0 -32
- package/dist/node_modules/.pnpm/change-case-all@1.0.15/node_modules/change-case-all/dist/index.js +0 -56
- package/dist/node_modules/.pnpm/change-case@4.1.2/node_modules/change-case/dist/index.js +0 -37
- package/dist/node_modules/.pnpm/constant-case@3.0.4/node_modules/constant-case/dist/index.js +0 -28
- package/dist/node_modules/.pnpm/dot-case@3.0.4/node_modules/dot-case/dist/index.js +0 -23
- package/dist/node_modules/.pnpm/header-case@2.0.4/node_modules/header-case/dist/index.js +0 -23
- package/dist/node_modules/.pnpm/is-lower-case@2.0.2/node_modules/is-lower-case/dist/index.js +0 -21
- package/dist/node_modules/.pnpm/is-upper-case@2.0.2/node_modules/is-upper-case/dist/index.js +0 -21
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Hash.js +0 -37
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_ListCache.js +0 -37
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Map.js +0 -15
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_MapCache.js +0 -37
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Stack.js +0 -34
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Symbol.js +0 -15
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Uint8Array.js +0 -15
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_apply.js +0 -30
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayLikeKeys.js +0 -35
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_assignMergeValue.js +0 -26
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_assignValue.js +0 -32
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_assocIndexOf.js +0 -26
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseAssignValue.js +0 -31
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseCreate.js +0 -34
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseFor.js +0 -25
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseGetTag.js +0 -30
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseIsArguments.js +0 -26
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseIsNative.js +0 -44
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseIsTypedArray.js +0 -32
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseKeysIn.js +0 -32
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseMerge.js +0 -42
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseMergeDeep.js +0 -75
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseRest.js +0 -26
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseSetToString.js +0 -31
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseTimes.js +0 -25
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseUnary.js +0 -23
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_cloneArrayBuffer.js +0 -25
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_cloneBuffer.js +0 -35
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_cloneTypedArray.js +0 -25
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_copyArray.js +0 -25
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_copyObject.js +0 -37
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_coreJsData.js +0 -15
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_createAssigner.js +0 -37
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_createBaseFor.js +0 -28
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_defineProperty.js +0 -20
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_freeGlobal.js +0 -13
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_getMapData.js +0 -25
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_getNative.js +0 -26
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_getPrototype.js +0 -15
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_getRawTag.js +0 -43
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_getValue.js +0 -22
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_hashClear.js +0 -24
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_hashDelete.js +0 -26
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_hashGet.js +0 -36
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_hashHas.js +0 -30
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_hashSet.js +0 -31
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_initCloneObject.js +0 -25
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_isIndex.js +0 -28
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_isIterateeCall.js +0 -32
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_isKeyable.js +0 -22
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_isMasked.js +0 -28
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_isPrototype.js +0 -24
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheClear.js +0 -22
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheDelete.js +0 -35
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheGet.js +0 -26
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheHas.js +0 -25
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheSet.js +0 -31
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_mapCacheClear.js +0 -30
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_mapCacheDelete.js +0 -27
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_mapCacheGet.js +0 -25
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_mapCacheHas.js +0 -25
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_mapCacheSet.js +0 -29
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_nativeCreate.js +0 -14
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_nativeKeysIn.js +0 -25
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_nodeUtil.js +0 -29
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_objectToString.js +0 -29
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_overArg.js +0 -24
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_overRest.js +0 -35
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_root.js +0 -17
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_safeGet.js +0 -24
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_setToString.js +0 -23
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_shortOut.js +0 -34
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_stackClear.js +0 -24
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_stackDelete.js +0 -25
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_stackGet.js +0 -23
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_stackHas.js +0 -23
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_stackSet.js +0 -42
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_toSource.js +0 -33
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/constant.js +0 -35
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/eq.js +0 -46
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/identity.js +0 -30
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isArguments.js +0 -43
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isArray.js +0 -35
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isArrayLike.js +0 -42
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isArrayLikeObject.js +0 -42
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isBuffer.js +0 -41
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isFunction.js +0 -38
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isLength.js +0 -42
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isObject.js +0 -40
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isObjectLike.js +0 -38
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isPlainObject.js +0 -60
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isTypedArray.js +0 -34
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/keysIn.js +0 -41
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/merge.js +0 -48
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/stubFalse.js +0 -27
- package/dist/node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/toPlainObject.js +0 -41
- package/dist/node_modules/.pnpm/lower-case-first@2.0.2/node_modules/lower-case-first/dist/index.js +0 -21
- package/dist/node_modules/.pnpm/lower-case@2.0.2/node_modules/lower-case/dist/index.js +0 -64
- package/dist/node_modules/.pnpm/no-case@3.0.4/node_modules/no-case/dist/index.js +0 -41
- package/dist/node_modules/.pnpm/param-case@3.0.4/node_modules/param-case/dist/index.js +0 -23
- package/dist/node_modules/.pnpm/pascal-case@3.1.2/node_modules/pascal-case/dist/index.js +0 -37
- package/dist/node_modules/.pnpm/path-case@3.0.4/node_modules/path-case/dist/index.js +0 -23
- package/dist/node_modules/.pnpm/sentence-case@3.0.4/node_modules/sentence-case/dist/index.js +0 -34
- package/dist/node_modules/.pnpm/snake-case@3.0.4/node_modules/snake-case/dist/index.js +0 -23
- package/dist/node_modules/.pnpm/sponge-case@1.0.1/node_modules/sponge-case/dist/index.js +0 -20
- package/dist/node_modules/.pnpm/swap-case@2.0.2/node_modules/swap-case/dist/index.js +0 -23
- package/dist/node_modules/.pnpm/title-case@3.0.3/node_modules/title-case/dist/index.js +0 -35
- package/dist/node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.js +0 -547
- package/dist/node_modules/.pnpm/upper-case-first@2.0.2/node_modules/upper-case-first/dist/index.js +0 -21
- package/dist/node_modules/.pnpm/upper-case@2.0.2/node_modules/upper-case/dist/index.js +0 -56
package/README.md
CHANGED
|
@@ -67,13 +67,13 @@ yarn add nitro-graphql graphql-yoga graphql
|
|
|
67
67
|
**For Apollo Server:**
|
|
68
68
|
```bash
|
|
69
69
|
# npm
|
|
70
|
-
npm install nitro-graphql @apollo/server graphql
|
|
70
|
+
npm install nitro-graphql @apollo/server @apollo/utils.withrequired @as-integrations/h3 graphql
|
|
71
71
|
|
|
72
72
|
# pnpm (recommended)
|
|
73
|
-
pnpm add nitro-graphql @apollo/server graphql
|
|
73
|
+
pnpm add nitro-graphql @apollo/server @apollo/utils.withrequired @as-integrations/h3 graphql
|
|
74
74
|
|
|
75
75
|
# yarn
|
|
76
|
-
yarn add nitro-graphql @apollo/server graphql
|
|
76
|
+
yarn add nitro-graphql @apollo/server @apollo/utils.withrequired @as-integrations/h3 graphql
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
### Step 2: Setup Your Project
|
package/dist/graphql/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/graphql/server.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from "./types/standard-schema.js";
|
|
2
2
|
import { CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, GenImport, GenericSdkConfig, NitroGraphQLOptions } from "./types/index.js";
|
|
3
|
-
import * as
|
|
3
|
+
import * as nitropack0 from "nitropack";
|
|
4
4
|
|
|
5
5
|
//#region src/index.d.ts
|
|
6
|
-
declare const _default:
|
|
6
|
+
declare const _default: nitropack0.NitroModule;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, GenImport, GenericSdkConfig, NitroGraphQLOptions, StandardSchemaV1, _default as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h30 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/apollo-server.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h30.EventHandler<h30.EventHandlerRequest, any>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
|
@@ -13,7 +13,11 @@ import { makeExecutableSchema } from "@graphql-tools/schema";
|
|
|
13
13
|
function createMergedSchema() {
|
|
14
14
|
try {
|
|
15
15
|
const mergedSchemas = schemas.map((schema$1) => schema$1.def).join("\n\n");
|
|
16
|
-
const typeDefs = mergeTypeDefs([mergedSchemas]
|
|
16
|
+
const typeDefs = mergeTypeDefs([mergedSchemas], {
|
|
17
|
+
throwOnConflict: true,
|
|
18
|
+
commentDescriptions: true,
|
|
19
|
+
sort: true
|
|
20
|
+
});
|
|
17
21
|
const mergedResolvers = mergeResolvers(resolvers.map((r) => r.resolver));
|
|
18
22
|
let schema = makeExecutableSchema({
|
|
19
23
|
typeDefs,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h33 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/graphql-yoga.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h33.EventHandler<h33.EventHandlerRequest, Promise<Response>>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { _default as default };
|
|
@@ -29,7 +29,11 @@ new window.EmbeddedSandbox({
|
|
|
29
29
|
function createMergedSchema() {
|
|
30
30
|
try {
|
|
31
31
|
const mergedSchemas = schemas.map((schema$1) => schema$1.def).join("\n\n");
|
|
32
|
-
const typeDefs = mergeTypeDefs([mergedSchemas]
|
|
32
|
+
const typeDefs = mergeTypeDefs([mergedSchemas], {
|
|
33
|
+
throwOnConflict: true,
|
|
34
|
+
commentDescriptions: true,
|
|
35
|
+
sort: true
|
|
36
|
+
});
|
|
33
37
|
const mergedResolvers = mergeResolvers(resolvers.map((r) => r.resolver));
|
|
34
38
|
let schema = makeExecutableSchema({
|
|
35
39
|
typeDefs,
|
package/dist/routes/health.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as h31 from "h3";
|
|
2
2
|
|
|
3
3
|
//#region src/routes/health.d.ts
|
|
4
|
-
declare const _default:
|
|
4
|
+
declare const _default: h31.EventHandler<h31.EventHandlerRequest, Promise<{
|
|
5
5
|
status: string;
|
|
6
6
|
message: string;
|
|
7
7
|
timestamp: string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { preset } from "../node_modules/.pnpm/@graphql-codegen_import-types-preset@3.0.1_graphql@16.11.0/node_modules/@graphql-codegen/import-types-preset/esm/index.js";
|
|
2
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
2
|
import { consola as consola$1 } from "consola";
|
|
4
3
|
import { defu as defu$1 } from "defu";
|
|
@@ -7,6 +6,7 @@ import { parse } from "graphql";
|
|
|
7
6
|
import { printSchemaWithDirectives } from "@graphql-tools/utils";
|
|
8
7
|
import { createHash } from "node:crypto";
|
|
9
8
|
import { codegen } from "@graphql-codegen/core";
|
|
9
|
+
import { preset } from "@graphql-codegen/import-types-preset";
|
|
10
10
|
import { plugin } from "@graphql-codegen/typescript";
|
|
11
11
|
import { plugin as plugin$1 } from "@graphql-codegen/typescript-generic-sdk";
|
|
12
12
|
import { plugin as plugin$2 } from "@graphql-codegen/typescript-operations";
|
package/dist/utils/index.js
CHANGED
|
@@ -104,7 +104,18 @@ async function scanSchemas(nitro) {
|
|
|
104
104
|
}
|
|
105
105
|
async function scanDocs(nitro) {
|
|
106
106
|
const files = await scanDir(nitro, nitro.options.rootDir, nitro.graphql.dir.client, "**/*.graphql");
|
|
107
|
-
|
|
107
|
+
const externalServices = nitro.options.graphql?.externalServices || [];
|
|
108
|
+
const externalPatterns = externalServices.flatMap((service) => service.documents || []);
|
|
109
|
+
return files.filter((f) => !f.path.startsWith("external/")).filter((f) => {
|
|
110
|
+
const relativePath = f.path;
|
|
111
|
+
for (const pattern of externalPatterns) {
|
|
112
|
+
const cleanPattern = pattern.replace(/^app\/graphql\//, "");
|
|
113
|
+
const patternDir = cleanPattern.split("/")[0];
|
|
114
|
+
const fileDir = relativePath.split("/")[0];
|
|
115
|
+
if (patternDir === fileDir) return false;
|
|
116
|
+
}
|
|
117
|
+
return true;
|
|
118
|
+
}).map((f) => f.fullPath);
|
|
108
119
|
}
|
|
109
120
|
/**
|
|
110
121
|
* Scan documents for a specific external service
|
|
@@ -139,7 +150,7 @@ function validateExternalServices(services) {
|
|
|
139
150
|
if (!service.schema) errors.push(`${prefix}.schema is required`);
|
|
140
151
|
if (!service.endpoint || typeof service.endpoint !== "string") errors.push(`${prefix}.endpoint is required and must be a string`);
|
|
141
152
|
else try {
|
|
142
|
-
|
|
153
|
+
new URL(service.endpoint);
|
|
143
154
|
} catch {
|
|
144
155
|
errors.push(`${prefix}.endpoint "${service.endpoint}" must be a valid URL`);
|
|
145
156
|
}
|
|
@@ -2,8 +2,8 @@ import { downloadAndSaveSchema, generateClientTypes, generateExternalClientTypes
|
|
|
2
2
|
import { generateTypes } from "./server-codegen.js";
|
|
3
3
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
4
|
import consola from "consola";
|
|
5
|
-
import { dirname, join, resolve } from "pathe";
|
|
6
|
-
import {
|
|
5
|
+
import { basename, dirname, join, resolve } from "pathe";
|
|
6
|
+
import { buildSchema, parse } from "graphql";
|
|
7
7
|
import { loadFilesSync } from "@graphql-tools/load-files";
|
|
8
8
|
import { mergeTypeDefs } from "@graphql-tools/merge";
|
|
9
9
|
import { printSchemaWithDirectives } from "@graphql-tools/utils";
|
|
@@ -89,6 +89,98 @@ export const $${serviceName}Sdk: Sdk = getSdk(create${capitalizedServiceName}Gra
|
|
|
89
89
|
writeFileSync(ofetchPath, ofetchContent, "utf-8");
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Check for duplicate type definitions using a simpler approach
|
|
94
|
+
* Try to build each schema individually - if that succeeds but merging fails, we have duplicates
|
|
95
|
+
* @returns true if validation passes, false if duplicates found
|
|
96
|
+
*/
|
|
97
|
+
function validateNoDuplicateTypes(schemas, schemaStrings) {
|
|
98
|
+
const individualSchemasByFile = /* @__PURE__ */ new Map();
|
|
99
|
+
schemaStrings.forEach((schemaContent, index) => {
|
|
100
|
+
const schemaPath = schemas[index];
|
|
101
|
+
const fileName = basename(schemaPath);
|
|
102
|
+
try {
|
|
103
|
+
parse(schemaContent);
|
|
104
|
+
individualSchemasByFile.set(fileName, schemaContent);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
consola.warn(`Invalid GraphQL syntax in ${fileName}:`, error);
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
try {
|
|
111
|
+
mergeTypeDefs([schemaStrings.join("\n\n")], {
|
|
112
|
+
throwOnConflict: false,
|
|
113
|
+
commentDescriptions: true,
|
|
114
|
+
sort: true
|
|
115
|
+
});
|
|
116
|
+
mergeTypeDefs([schemaStrings.join("\n\n")], {
|
|
117
|
+
throwOnConflict: true,
|
|
118
|
+
commentDescriptions: true,
|
|
119
|
+
sort: true
|
|
120
|
+
});
|
|
121
|
+
} catch (conflictError) {
|
|
122
|
+
if (conflictError?.message?.includes("already defined with a different type")) throw conflictError;
|
|
123
|
+
}
|
|
124
|
+
const typeNames = /* @__PURE__ */ new Set();
|
|
125
|
+
const duplicateTypes = [];
|
|
126
|
+
schemaStrings.forEach((schemaContent, index) => {
|
|
127
|
+
const fileName = basename(schemas[index]);
|
|
128
|
+
try {
|
|
129
|
+
const document = parse(schemaContent);
|
|
130
|
+
document.definitions.forEach((def) => {
|
|
131
|
+
if (def.kind === "ObjectTypeDefinition" || def.kind === "InterfaceTypeDefinition" || def.kind === "UnionTypeDefinition" || def.kind === "EnumTypeDefinition" || def.kind === "InputObjectTypeDefinition" || def.kind === "ScalarTypeDefinition") {
|
|
132
|
+
const typeName = def.name.value;
|
|
133
|
+
if ([
|
|
134
|
+
"String",
|
|
135
|
+
"Int",
|
|
136
|
+
"Float",
|
|
137
|
+
"Boolean",
|
|
138
|
+
"ID",
|
|
139
|
+
"DateTime",
|
|
140
|
+
"JSON"
|
|
141
|
+
].includes(typeName)) return;
|
|
142
|
+
if (typeNames.has(typeName)) {
|
|
143
|
+
const existing = duplicateTypes.find((d) => d.type === typeName);
|
|
144
|
+
if (existing) existing.files.push(fileName);
|
|
145
|
+
else {
|
|
146
|
+
const firstFile = schemas.find((_, i) => {
|
|
147
|
+
const content = schemaStrings[i];
|
|
148
|
+
if (!content) return false;
|
|
149
|
+
try {
|
|
150
|
+
const doc = parse(content);
|
|
151
|
+
return doc.definitions.some((d) => (d.kind === "ObjectTypeDefinition" || d.kind === "InterfaceTypeDefinition" || d.kind === "UnionTypeDefinition" || d.kind === "EnumTypeDefinition" || d.kind === "InputObjectTypeDefinition" || d.kind === "ScalarTypeDefinition") && d.name.value === typeName);
|
|
152
|
+
} catch {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
duplicateTypes.push({
|
|
157
|
+
type: typeName,
|
|
158
|
+
files: [basename(firstFile || ""), fileName]
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
} else typeNames.add(typeName);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
} catch {}
|
|
165
|
+
});
|
|
166
|
+
if (duplicateTypes.length > 0) {
|
|
167
|
+
let errorMessage = "⚠️ DUPLICATE TYPE DEFINITIONS DETECTED!\n\n";
|
|
168
|
+
duplicateTypes.forEach(({ type, files }) => {
|
|
169
|
+
errorMessage += `❌ Type "${type}" is defined in multiple files:\n`;
|
|
170
|
+
files.forEach((fileName) => {
|
|
171
|
+
const fullPath = schemas.find((path) => basename(path) === fileName) || fileName;
|
|
172
|
+
errorMessage += ` • ${fullPath}\n`;
|
|
173
|
+
});
|
|
174
|
+
errorMessage += "\n";
|
|
175
|
+
});
|
|
176
|
+
errorMessage += "💡 Each GraphQL type should only be defined once.\n";
|
|
177
|
+
errorMessage += " Consider using \"extend type\" syntax instead of duplicate definitions.\n";
|
|
178
|
+
errorMessage += `\n🔍 Found ${duplicateTypes.length} duplicate type(s): ${duplicateTypes.map((d) => d.type).join(", ")}`;
|
|
179
|
+
consola.error(errorMessage);
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
92
184
|
async function serverTypeGeneration(app) {
|
|
93
185
|
try {
|
|
94
186
|
const schemas = app.scanSchemas || [];
|
|
@@ -97,11 +189,16 @@ async function serverTypeGeneration(app) {
|
|
|
97
189
|
return;
|
|
98
190
|
}
|
|
99
191
|
const loadSchemas = loadFilesSync(schemas);
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
192
|
+
const schemaStrings = loadSchemas.map((schema$1) => typeof schema$1 === "string" ? schema$1 : schema$1.loc?.source?.body || "").filter(Boolean);
|
|
193
|
+
const isValid = validateNoDuplicateTypes(schemas, schemaStrings);
|
|
194
|
+
if (!isValid) return;
|
|
195
|
+
const mergedSchemasString = schemaStrings.join("\n\n");
|
|
196
|
+
const mergedSchemas = mergeTypeDefs([mergedSchemasString], {
|
|
197
|
+
throwOnConflict: true,
|
|
198
|
+
commentDescriptions: true,
|
|
199
|
+
sort: true
|
|
104
200
|
});
|
|
201
|
+
const schema = buildSchema(mergedSchemas);
|
|
105
202
|
const data = await generateTypes(app.options.graphql?.framework || "graphql-yoga", schema, app.options.graphql?.codegen?.server ?? {});
|
|
106
203
|
const printSchema = printSchemaWithDirectives(schema);
|
|
107
204
|
const schemaPath = resolve(app.graphql.buildDir, "schema.graphql");
|
|
@@ -172,9 +269,7 @@ async function generateMainClientTypes(nitro) {
|
|
|
172
269
|
mkdirSync(defaultServiceDir, { recursive: true });
|
|
173
270
|
writeFileSync(sdkTypesPath, types.sdk, "utf-8");
|
|
174
271
|
if (nitro.options.framework?.name === "nuxt") {
|
|
175
|
-
|
|
176
|
-
const hasUserGraphqlSetup = existsSync(appGraphqlDir);
|
|
177
|
-
if (!hasUserGraphqlSetup) generateNuxtOfetchClient(nitro.graphql.clientDir, "default");
|
|
272
|
+
generateNuxtOfetchClient(nitro.graphql.clientDir, "default");
|
|
178
273
|
const externalServices = nitro.options.graphql?.externalServices || [];
|
|
179
274
|
generateGraphQLIndexFile(nitro.graphql.clientDir, externalServices);
|
|
180
275
|
}
|
|
@@ -193,8 +288,13 @@ async function generateExternalServicesTypes(nitro) {
|
|
|
193
288
|
let loadDocs = [];
|
|
194
289
|
if (documentPatterns.length > 0) try {
|
|
195
290
|
loadDocs = await loadGraphQLDocuments(documentPatterns);
|
|
291
|
+
if (!loadDocs || loadDocs.length === 0) {
|
|
292
|
+
consola.warn(`[graphql:${service.name}] No GraphQL documents found, skipping service generation`);
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
196
295
|
} catch (error) {
|
|
197
|
-
consola.warn(`[graphql:${service.name}] No documents found:`, error);
|
|
296
|
+
consola.warn(`[graphql:${service.name}] No documents found, skipping service generation:`, error);
|
|
297
|
+
continue;
|
|
198
298
|
}
|
|
199
299
|
const types = await generateExternalClientTypes(service, schema, loadDocs);
|
|
200
300
|
if (types === false) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-graphql",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"description": "GraphQL integration for Nitro",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -55,25 +55,38 @@
|
|
|
55
55
|
"dist"
|
|
56
56
|
],
|
|
57
57
|
"peerDependencies": {
|
|
58
|
+
"@apollo/server": "^5.0.0",
|
|
59
|
+
"@apollo/utils.withrequired": "^3.0.0",
|
|
60
|
+
"@as-integrations/h3": "^2.0.0",
|
|
58
61
|
"graphql": "^16.11.0",
|
|
59
62
|
"h3": "^1.15.3",
|
|
60
63
|
"nitropack": "^2.11.13"
|
|
61
64
|
},
|
|
65
|
+
"peerDependenciesMeta": {
|
|
66
|
+
"@apollo/server": {
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"@apollo/utils.withrequired": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"@as-integrations/h3": {
|
|
73
|
+
"optional": true
|
|
74
|
+
}
|
|
75
|
+
},
|
|
62
76
|
"dependencies": {
|
|
63
|
-
"@apollo/utils.withrequired": "^3.0.0",
|
|
64
|
-
"@as-integrations/h3": "^2.0.0",
|
|
65
77
|
"@graphql-codegen/core": "^4.0.2",
|
|
78
|
+
"@graphql-codegen/import-types-preset": "^3.0.1",
|
|
66
79
|
"@graphql-codegen/typescript": "^4.1.6",
|
|
67
80
|
"@graphql-codegen/typescript-generic-sdk": "^4.0.2",
|
|
68
81
|
"@graphql-codegen/typescript-operations": "^4.6.1",
|
|
69
82
|
"@graphql-codegen/typescript-resolvers": "^4.5.1",
|
|
70
|
-
"@graphql-tools/graphql-file-loader": "^8.0
|
|
71
|
-
"@graphql-tools/load": "^8.1.
|
|
83
|
+
"@graphql-tools/graphql-file-loader": "^8.1.0",
|
|
84
|
+
"@graphql-tools/load": "^8.1.2",
|
|
72
85
|
"@graphql-tools/load-files": "^7.0.1",
|
|
73
|
-
"@graphql-tools/merge": "^9.1.
|
|
74
|
-
"@graphql-tools/schema": "^10.0.
|
|
86
|
+
"@graphql-tools/merge": "^9.1.1",
|
|
87
|
+
"@graphql-tools/schema": "^10.0.25",
|
|
75
88
|
"@graphql-tools/url-loader": "^8.0.33",
|
|
76
|
-
"@graphql-tools/utils": "^10.9.
|
|
89
|
+
"@graphql-tools/utils": "^10.9.1",
|
|
77
90
|
"chokidar": "^4.0.3",
|
|
78
91
|
"consola": "^3.4.2",
|
|
79
92
|
"defu": "^6.1.4",
|
|
@@ -81,27 +94,25 @@
|
|
|
81
94
|
"graphql-scalars": "^1.24.2",
|
|
82
95
|
"knitwork": "^1.2.0",
|
|
83
96
|
"ohash": "^2.0.11",
|
|
84
|
-
"oxc-parser": "^0.
|
|
97
|
+
"oxc-parser": "^0.82.3",
|
|
85
98
|
"pathe": "^2.0.3",
|
|
86
99
|
"tinyglobby": "^0.2.14"
|
|
87
100
|
},
|
|
88
101
|
"devDependencies": {
|
|
89
|
-
"@antfu/eslint-config": "^
|
|
90
|
-
"@apollo/server": "^5.0.0",
|
|
91
|
-
"@graphql-codegen/import-types-preset": "^3.0.1",
|
|
102
|
+
"@antfu/eslint-config": "^5.2.1",
|
|
92
103
|
"@nuxt/kit": "^4.0.3",
|
|
93
104
|
"@nuxt/schema": "^4.0.3",
|
|
94
|
-
"@types/node": "^
|
|
95
|
-
"bumpp": "^10.2.
|
|
105
|
+
"@types/node": "^22.18.0",
|
|
106
|
+
"bumpp": "^10.2.3",
|
|
96
107
|
"changelogen": "^0.6.2",
|
|
97
108
|
"crossws": "0.3.5",
|
|
98
|
-
"eslint": "^9.
|
|
109
|
+
"eslint": "^9.34.0",
|
|
99
110
|
"graphql": "^16.11.0",
|
|
100
111
|
"graphql-yoga": "^5.15.1",
|
|
101
112
|
"h3": "1.15.3",
|
|
102
|
-
"nitropack": "^2.12.
|
|
103
|
-
"tsdown": "^0.
|
|
104
|
-
"typescript": "^5.
|
|
113
|
+
"nitropack": "^2.12.4",
|
|
114
|
+
"tsdown": "^0.14.2",
|
|
115
|
+
"typescript": "^5.9.2"
|
|
105
116
|
},
|
|
106
117
|
"resolutions": {
|
|
107
118
|
"nitro-graphql": "link:."
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res) => function() {
|
|
9
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
-
};
|
|
11
|
-
var __commonJS = (cb, mod) => function() {
|
|
12
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
-
};
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all) __defProp(target, name, {
|
|
16
|
-
get: all[name],
|
|
17
|
-
enumerable: true
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
22
|
-
key = keys[i];
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
24
|
-
get: ((k) => from[k]).bind(null, key),
|
|
25
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return to;
|
|
29
|
-
};
|
|
30
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
31
|
-
value: mod,
|
|
32
|
-
enumerable: true
|
|
33
|
-
}) : target, mod));
|
|
34
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
|
-
export { __commonJS, __esm, __export, __toCommonJS, __toESM };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { VALID_PLACEMENTS } from "./config.js";
|
|
2
|
-
|
|
3
|
-
//#region node_modules/.pnpm/@graphql-codegen+add@3.2.3_graphql@16.11.0/node_modules/@graphql-codegen/add/esm/index.js
|
|
4
|
-
const plugin = async (schema, documents, config) => {
|
|
5
|
-
const placement = config.placement || "prepend";
|
|
6
|
-
const { content } = config;
|
|
7
|
-
if (!VALID_PLACEMENTS.includes(placement)) throw Error(`Configuration provided for 'add' plugin is invalid: value of 'placement' field is not valid (valid values are: ${VALID_PLACEMENTS.join(", ")})`);
|
|
8
|
-
if (!content) throw Error(`Configuration provided for 'add' plugin is invalid: "content" is missing!`);
|
|
9
|
-
return {
|
|
10
|
-
content: null,
|
|
11
|
-
[placement]: Array.isArray(content) ? content : [content]
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
var esm_default = { plugin };
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
export { esm_default as default };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import esm_default from "../../../../../@graphql-codegen_add@3.2.3_graphql@16.11.0/node_modules/@graphql-codegen/add/esm/index.js";
|
|
2
|
-
import { isUsingTypes } from "../../../../../@graphql-codegen_plugin-helpers@3.1.2_graphql@16.11.0/node_modules/@graphql-codegen/plugin-helpers/esm/helpers.js";
|
|
3
|
-
import "../../../../../@graphql-codegen_plugin-helpers@3.1.2_graphql@16.11.0/node_modules/@graphql-codegen/plugin-helpers/esm/index.js";
|
|
4
|
-
|
|
5
|
-
//#region node_modules/.pnpm/@graphql-codegen+import-types-preset@3.0.1_graphql@16.11.0/node_modules/@graphql-codegen/import-types-preset/esm/index.js
|
|
6
|
-
const preset = { buildGeneratesSection: (options) => {
|
|
7
|
-
if (!options.presetConfig.typesPath) throw new Error(`Preset "import-types" requires you to specify "typesPath" configuration and point it to your base types file (generated by "typescript" plugin)!`);
|
|
8
|
-
const importTypesNamespace = options.presetConfig.importTypesNamespace || "Types";
|
|
9
|
-
const pluginMap = {
|
|
10
|
-
...options.pluginMap,
|
|
11
|
-
add: esm_default
|
|
12
|
-
};
|
|
13
|
-
const plugins = [...options.plugins];
|
|
14
|
-
const config = {
|
|
15
|
-
...options.config,
|
|
16
|
-
namespacedImportName: importTypesNamespace,
|
|
17
|
-
importOperationTypesFrom: importTypesNamespace,
|
|
18
|
-
externalFragments: []
|
|
19
|
-
};
|
|
20
|
-
options.documents.map((documentFile) => {
|
|
21
|
-
if (isUsingTypes(documentFile.document, config.externalFragments.map((m) => m.name), options.schemaAst)) {
|
|
22
|
-
const importType = options.config.useTypeImports ? "import type" : "import";
|
|
23
|
-
plugins.unshift({ add: { content: `${importType} * as ${importTypesNamespace} from '${options.presetConfig.typesPath}';\n` } });
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
return [{
|
|
27
|
-
filename: options.baseOutputDir,
|
|
28
|
-
plugins,
|
|
29
|
-
pluginMap,
|
|
30
|
-
config,
|
|
31
|
-
schema: options.schema,
|
|
32
|
-
schemaAst: options.schemaAst,
|
|
33
|
-
documents: options.documents
|
|
34
|
-
}];
|
|
35
|
-
} };
|
|
36
|
-
|
|
37
|
-
//#endregion
|
|
38
|
-
export { preset };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { __toESM } from "../../../../../../../_virtual/rolldown_runtime.js";
|
|
2
|
-
import "./utils.js";
|
|
3
|
-
import { require_merge } from "../../../../../lodash@4.17.21/node_modules/lodash/merge.js";
|
|
4
|
-
import "./index.js";
|
|
5
|
-
import { isObjectType, parse } from "graphql";
|
|
6
|
-
import "@graphql-tools/utils";
|
|
7
|
-
|
|
8
|
-
//#region node_modules/.pnpm/@graphql-codegen+plugin-helpers@3.1.2_graphql@16.11.0/node_modules/@graphql-codegen/plugin-helpers/esm/federation.js
|
|
9
|
-
var import_merge = __toESM(require_merge(), 1);
|
|
10
|
-
/**
|
|
11
|
-
* Federation Spec
|
|
12
|
-
*/
|
|
13
|
-
const federationSpec = parse(`
|
|
14
|
-
scalar _FieldSet
|
|
15
|
-
|
|
16
|
-
directive @external on FIELD_DEFINITION
|
|
17
|
-
directive @requires(fields: _FieldSet!) on FIELD_DEFINITION
|
|
18
|
-
directive @provides(fields: _FieldSet!) on FIELD_DEFINITION
|
|
19
|
-
directive @key(fields: _FieldSet!) on OBJECT | INTERFACE
|
|
20
|
-
`);
|
|
21
|
-
|
|
22
|
-
//#endregion
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { getDocumentNodeFromSchema, memoize1 } from "@graphql-tools/utils";
|
|
2
|
-
|
|
3
|
-
//#region node_modules/.pnpm/@graphql-codegen+plugin-helpers@3.1.2_graphql@16.11.0/node_modules/@graphql-codegen/plugin-helpers/esm/getCachedDocumentNodeFromSchema.js
|
|
4
|
-
const getCachedDocumentNodeFromSchema = memoize1(getDocumentNodeFromSchema);
|
|
5
|
-
|
|
6
|
-
//#endregion
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { getBaseType } from "./utils.js";
|
|
2
|
-
import { Kind, isListType, isNonNullType, isObjectType, visit } from "graphql";
|
|
3
|
-
|
|
4
|
-
//#region node_modules/.pnpm/@graphql-codegen+plugin-helpers@3.1.2_graphql@16.11.0/node_modules/@graphql-codegen/plugin-helpers/esm/helpers.js
|
|
5
|
-
function hasNullableTypeRecursively(type) {
|
|
6
|
-
if (!isNonNullType(type)) return true;
|
|
7
|
-
if (isListType(type) || isNonNullType(type)) return hasNullableTypeRecursively(type.ofType);
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
function isUsingTypes(document, externalFragments, schema) {
|
|
11
|
-
let foundFields = 0;
|
|
12
|
-
const typesStack = [];
|
|
13
|
-
visit(document, {
|
|
14
|
-
SelectionSet: {
|
|
15
|
-
enter(node, key, parent, anscestors) {
|
|
16
|
-
const insideIgnoredFragment = anscestors.find((f) => f.kind && f.kind === "FragmentDefinition" && externalFragments.includes(f.name.value));
|
|
17
|
-
if (insideIgnoredFragment) return;
|
|
18
|
-
const selections = node.selections || [];
|
|
19
|
-
if (schema && selections.length > 0) {
|
|
20
|
-
const nextTypeName = (() => {
|
|
21
|
-
if (parent.kind === Kind.FRAGMENT_DEFINITION) return parent.typeCondition.name.value;
|
|
22
|
-
if (parent.kind === Kind.FIELD) {
|
|
23
|
-
const lastType = typesStack[typesStack.length - 1];
|
|
24
|
-
if (!lastType) throw new Error(`Unable to find parent type! Please make sure you operation passes validation`);
|
|
25
|
-
const field = lastType.getFields()[parent.name.value];
|
|
26
|
-
if (!field) throw new Error(`Unable to find field "${parent.name.value}" on type "${lastType}"!`);
|
|
27
|
-
return getBaseType(field.type).name;
|
|
28
|
-
}
|
|
29
|
-
if (parent.kind === Kind.OPERATION_DEFINITION) {
|
|
30
|
-
if (parent.operation === "query") return schema.getQueryType().name;
|
|
31
|
-
if (parent.operation === "mutation") return schema.getMutationType().name;
|
|
32
|
-
if (parent.operation === "subscription") return schema.getSubscriptionType().name;
|
|
33
|
-
} else if (parent.kind === Kind.INLINE_FRAGMENT) {
|
|
34
|
-
if (parent.typeCondition) return parent.typeCondition.name.value;
|
|
35
|
-
return typesStack[typesStack.length - 1].name;
|
|
36
|
-
}
|
|
37
|
-
return null;
|
|
38
|
-
})();
|
|
39
|
-
typesStack.push(schema.getType(nextTypeName));
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
leave(node) {
|
|
43
|
-
const selections = node.selections || [];
|
|
44
|
-
if (schema && selections.length > 0) typesStack.pop();
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
Field: { enter: (node, key, parent, path, anscestors) => {
|
|
48
|
-
if (node.name.value.startsWith("__")) return;
|
|
49
|
-
const insideIgnoredFragment = anscestors.find((f) => f.kind && f.kind === "FragmentDefinition" && externalFragments.includes(f.name.value));
|
|
50
|
-
if (insideIgnoredFragment) return;
|
|
51
|
-
const selections = node.selectionSet ? node.selectionSet.selections || [] : [];
|
|
52
|
-
const relevantFragmentSpreads = selections.filter((s) => s.kind === Kind.FRAGMENT_SPREAD && !externalFragments.includes(s.name.value));
|
|
53
|
-
if (selections.length === 0 || relevantFragmentSpreads.length > 0) foundFields++;
|
|
54
|
-
if (schema) {
|
|
55
|
-
const lastType = typesStack[typesStack.length - 1];
|
|
56
|
-
if (lastType && isObjectType(lastType)) {
|
|
57
|
-
const field = lastType.getFields()[node.name.value];
|
|
58
|
-
if (!field) throw new Error(`Unable to find field "${node.name.value}" on type "${lastType}"!`);
|
|
59
|
-
const currentType = field.type;
|
|
60
|
-
if (hasNullableTypeRecursively(currentType)) foundFields++;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
} },
|
|
64
|
-
VariableDefinition: { enter: (node, key, parent, path, anscestors) => {
|
|
65
|
-
const insideIgnoredFragment = anscestors.find((f) => f.kind && f.kind === "FragmentDefinition" && externalFragments.includes(f.name.value));
|
|
66
|
-
if (insideIgnoredFragment) return;
|
|
67
|
-
foundFields++;
|
|
68
|
-
} },
|
|
69
|
-
InputValueDefinition: { enter: (node, key, parent, path, anscestors) => {
|
|
70
|
-
const insideIgnoredFragment = anscestors.find((f) => f.kind && f.kind === "FragmentDefinition" && externalFragments.includes(f.name.value));
|
|
71
|
-
if (insideIgnoredFragment) return;
|
|
72
|
-
foundFields++;
|
|
73
|
-
} }
|
|
74
|
-
});
|
|
75
|
-
return foundFields > 0;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
//#endregion
|
|
79
|
-
export { hasNullableTypeRecursively, isUsingTypes };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import "./resolve-external-module-and-fn.js";
|
|
2
|
-
import { getBaseType, isWrapperType } from "./utils.js";
|
|
3
|
-
import { hasNullableTypeRecursively, isUsingTypes } from "./helpers.js";
|
|
4
|
-
import "./federation.js";
|
|
5
|
-
import "./getCachedDocumentNodeFromSchema.js";
|
|
6
|
-
import "./oldVisit.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import { visit } from "graphql";
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { __toESM } from "../../../../../../../_virtual/rolldown_runtime.js";
|
|
2
|
-
import { require_dist } from "../../../../../change-case-all@1.0.15/node_modules/change-case-all/dist/index.js";
|
|
3
|
-
|
|
4
|
-
//#region node_modules/.pnpm/@graphql-codegen+plugin-helpers@3.1.2_graphql@16.11.0/node_modules/@graphql-codegen/plugin-helpers/esm/resolve-external-module-and-fn.js
|
|
5
|
-
var import_dist = __toESM(require_dist(), 1);
|
|
6
|
-
|
|
7
|
-
//#endregion
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { isListType, isNonNullType } from "graphql";
|
|
2
|
-
|
|
3
|
-
//#region node_modules/.pnpm/@graphql-codegen+plugin-helpers@3.1.2_graphql@16.11.0/node_modules/@graphql-codegen/plugin-helpers/esm/utils.js
|
|
4
|
-
function isWrapperType(t) {
|
|
5
|
-
return isListType(t) || isNonNullType(t);
|
|
6
|
-
}
|
|
7
|
-
function getBaseType(type) {
|
|
8
|
-
if (isWrapperType(type)) return getBaseType(type.ofType);
|
|
9
|
-
return type;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
export { getBaseType, isWrapperType };
|