nitro-graphql 1.4.1 → 1.4.2

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.
@@ -1,6 +1,6 @@
1
- import * as h33 from "h3";
1
+ import * as h30 from "h3";
2
2
 
3
3
  //#region src/routes/apollo-server.d.ts
4
- declare const _default: h33.EventHandler<h33.EventHandlerRequest, Promise<any>>;
4
+ declare const _default: h30.EventHandler<h30.EventHandlerRequest, Promise<any>>;
5
5
  //#endregion
6
6
  export { _default as default };
@@ -1,6 +1,6 @@
1
- import * as h30 from "h3";
1
+ import * as h33 from "h3";
2
2
 
3
3
  //#region src/routes/graphql-yoga.d.ts
4
- declare const _default: h30.EventHandler<h30.EventHandlerRequest, Promise<Response>>;
4
+ declare const _default: h33.EventHandler<h33.EventHandlerRequest, Promise<Response>>;
5
5
  //#endregion
6
6
  export { _default as default };
@@ -4,6 +4,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
4
  import consola from "consola";
5
5
  import { basename, dirname, join, resolve } from "pathe";
6
6
  import { buildSchema, parse } from "graphql";
7
+ import { buildSubgraphSchema } from "@apollo/subgraph";
7
8
  import { loadFilesSync } from "@graphql-tools/load-files";
8
9
  import { mergeTypeDefs } from "@graphql-tools/merge";
9
10
  import { printSchemaWithDirectives } from "@graphql-tools/utils";
@@ -192,36 +193,13 @@ async function serverTypeGeneration(app) {
192
193
  const schemaStrings = loadSchemas.map((schema$1) => typeof schema$1 === "string" ? schema$1 : schema$1.loc?.source?.body || "").filter(Boolean);
193
194
  const isValid = validateNoDuplicateTypes(schemas, schemaStrings);
194
195
  if (!isValid) return;
195
- const mergedSchemasString = schemaStrings.join("\n\n");
196
196
  const federationEnabled = app.options.graphql?.federation?.enabled === true;
197
- let schemaWithDirectives = mergedSchemasString;
198
- if (federationEnabled) {
199
- const federationDirectives = `
200
- directive @key(fields: String!) on OBJECT | INTERFACE
201
- directive @requires(fields: String!) on FIELD_DEFINITION
202
- directive @provides(fields: String!) on FIELD_DEFINITION
203
- directive @external on FIELD_DEFINITION | OBJECT
204
- directive @tag(name: String!) on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
205
- directive @extends on OBJECT | INTERFACE
206
- directive @shareable on FIELD_DEFINITION | OBJECT
207
- directive @inaccessible on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
208
- directive @override(from: String!) on FIELD_DEFINITION
209
- directive @composeDirective(name: String!) on SCHEMA
210
- directive @link(url: String!, as: String, for: Purpose, import: [String!]) on SCHEMA
211
-
212
- enum Purpose {
213
- SECURITY
214
- EXECUTION
215
- }
216
- `;
217
- schemaWithDirectives = `${federationDirectives}\n\n${mergedSchemasString}`;
218
- }
219
- const mergedSchemas = mergeTypeDefs([schemaWithDirectives], {
197
+ const mergedSchemas = mergeTypeDefs([schemaStrings.join("\n\n")], {
220
198
  throwOnConflict: true,
221
199
  commentDescriptions: true,
222
200
  sort: true
223
201
  });
224
- const schema = buildSchema(mergedSchemas);
202
+ const schema = federationEnabled ? buildSubgraphSchema([{ typeDefs: parse(mergedSchemas) }]) : buildSchema(mergedSchemas);
225
203
  const data = await generateTypes(app.options.graphql?.framework || "graphql-yoga", schema, app.options.graphql ?? {});
226
204
  const printSchema = printSchemaWithDirectives(schema);
227
205
  const schemaPath = resolve(app.graphql.buildDir, "schema.graphql");
@@ -281,7 +259,8 @@ async function generateMainClientTypes(nitro) {
281
259
  return;
282
260
  }
283
261
  const graphqlString = readFileSync(schemaFilePath, "utf-8");
284
- const schema = buildSchema(graphqlString);
262
+ const federationEnabled = nitro.options.graphql?.federation?.enabled === true;
263
+ const schema = federationEnabled ? buildSubgraphSchema([{ typeDefs: parse(graphqlString) }]) : buildSchema(graphqlString);
285
264
  const types = await generateClientTypes(schema, loadDocs, nitro.options.graphql?.codegen?.client ?? {}, nitro.options.graphql?.codegen?.clientSDK ?? {});
286
265
  if (types === false) return;
287
266
  const clientTypesPath = resolve(nitro.options.buildDir, "types", "nitro-graphql-client.d.ts");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nitro-graphql",
3
3
  "type": "module",
4
- "version": "1.4.1",
4
+ "version": "1.4.2",
5
5
  "description": "GraphQL integration for Nitro",
6
6
  "license": "MIT",
7
7
  "sideEffects": false,