@webiny/api-graphql 6.6.0-alpha.0 → 6.6.0-alpha.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,7 +1,12 @@
1
1
  import { DateResolver } from "graphql-scalars";
2
2
  import { GraphQLScalarType } from "graphql";
3
+ const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
3
4
  const DateScalar = new GraphQLScalarType({
4
5
  ...DateResolver,
6
+ parseValue: (value)=>{
7
+ if ("string" != typeof value || !DATE_RE.test(value)) throw new TypeError(`Date cannot represent an invalid date-string ${String(value)}. Expected format: YYYY-MM-DD.`);
8
+ return DateResolver.parseValue(value);
9
+ },
5
10
  serialize: (value)=>{
6
11
  if (!value) return null;
7
12
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"builtInTypes/DateScalar.js","sources":["../../src/builtInTypes/DateScalar.ts"],"sourcesContent":["import { DateResolver } from \"graphql-scalars\";\nimport { GraphQLScalarType } from \"graphql\";\nexport const DateScalar = new GraphQLScalarType<Date | string, string>({\n ...DateResolver,\n /**\n * We can set value as any because we are handling it.\n */\n serialize: (value: any) => {\n if (!value) {\n return null;\n }\n try {\n const date = new Date(value);\n return date.toISOString().slice(0, 10);\n } catch (ex) {\n if (value.toISOString) {\n return value.toISOString().slice(0, 10);\n }\n throw ex;\n }\n }\n});\n"],"names":["DateScalar","GraphQLScalarType","DateResolver","value","date","Date","ex"],"mappings":";;AAEO,MAAMA,aAAa,IAAIC,kBAAyC;IACnE,GAAGC,YAAY;IAIf,WAAW,CAACC;QACR,IAAI,CAACA,OACD,OAAO;QAEX,IAAI;YACA,MAAMC,OAAO,IAAIC,KAAKF;YACtB,OAAOC,KAAK,WAAW,GAAG,KAAK,CAAC,GAAG;QACvC,EAAE,OAAOE,IAAI;YACT,IAAIH,MAAM,WAAW,EACjB,OAAOA,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG;YAExC,MAAMG;QACV;IACJ;AACJ"}
1
+ {"version":3,"file":"builtInTypes/DateScalar.js","sources":["../../src/builtInTypes/DateScalar.ts"],"sourcesContent":["import { DateResolver } from \"graphql-scalars\";\nimport { GraphQLScalarType } from \"graphql\";\n\nconst DATE_RE = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nexport const DateScalar = new GraphQLScalarType<Date | string, string>({\n ...DateResolver,\n parseValue: (value: unknown) => {\n if (typeof value !== \"string\" || !DATE_RE.test(value)) {\n throw new TypeError(\n `Date cannot represent an invalid date-string ${String(value)}. Expected format: YYYY-MM-DD.`\n );\n }\n return DateResolver.parseValue(value);\n },\n serialize: (value: any) => {\n if (!value) {\n return null;\n }\n try {\n const date = new Date(value);\n return date.toISOString().slice(0, 10);\n } catch (ex) {\n if (value.toISOString) {\n return value.toISOString().slice(0, 10);\n }\n throw ex;\n }\n }\n});\n"],"names":["DATE_RE","DateScalar","GraphQLScalarType","DateResolver","value","TypeError","String","date","Date","ex"],"mappings":";;AAGA,MAAMA,UAAU;AAET,MAAMC,aAAa,IAAIC,kBAAyC;IACnE,GAAGC,YAAY;IACf,YAAY,CAACC;QACT,IAAI,AAAiB,YAAjB,OAAOA,SAAsB,CAACJ,QAAQ,IAAI,CAACI,QAC3C,MAAM,IAAIC,UACN,CAAC,6CAA6C,EAAEC,OAAOF,OAAO,8BAA8B,CAAC;QAGrG,OAAOD,aAAa,UAAU,CAACC;IACnC;IACA,WAAW,CAACA;QACR,IAAI,CAACA,OACD,OAAO;QAEX,IAAI;YACA,MAAMG,OAAO,IAAIC,KAAKJ;YACtB,OAAOG,KAAK,WAAW,GAAG,KAAK,CAAC,GAAG;QACvC,EAAE,OAAOE,IAAI;YACT,IAAIL,MAAM,WAAW,EACjB,OAAOA,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG;YAExC,MAAMK;QACV;IACJ;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"engine/GraphQLEngine.js","sources":["../../src/engine/GraphQLEngine.ts"],"sourcesContent":["import { graphql } from \"graphql\";\nimport { makeExecutableSchema, mergeSchemas } from \"@graphql-tools/schema\";\nimport { mergeResolvers } from \"@graphql-tools/merge\";\nimport { Container } from \"@webiny/di\";\nimport { RequestContainer } from \"@webiny/event-handler-core\";\nimport { GraphQLEngine as GraphQLEngineAbstraction } from \"./abstractions.js\";\nimport { GraphQLContextEnhancer } from \"./GraphQLContextEnhancer.js\";\nimport { GraphQLContextualSchema } from \"./GraphQLContextualSchema.js\";\nimport { GraphQLSchemaComposer } from \"~/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { ResolverDecoration } from \"~/ResolverDecoration.js\";\nimport { createRequestBody } from \"~/createRequestBody.js\";\nimport type { IGraphQLSchemaComposer } from \"~/features/GraphQLSchemaBuilder/abstractions.js\";\nimport type { IGraphQLContextEnhancer } from \"./GraphQLContextEnhancer.js\";\nimport type { IGraphQLContextualSchema } from \"./GraphQLContextualSchema.js\";\nimport type { GraphQLRequestBody } from \"~/types.js\";\nimport type { GraphQLSchema } from \"graphql\";\n\nclass GraphQLEngineImpl implements GraphQLEngineAbstraction.Interface {\n constructor(\n private composer: IGraphQLSchemaComposer,\n private container: Container,\n private enhancers: IGraphQLContextEnhancer[],\n private contextualSchemas: IGraphQLContextualSchema[]\n ) {}\n\n async execute(body: any): Promise<any> {\n // Build context first — enhancers may be async (e.g. CMS storage init)\n const ctx = await this.buildContext();\n\n // NOTE: the post-auth RequestContextInitializers (CMS facade, FileModel, ...) are run once\n // per request by the HTTP layer (RequestContextInitializerDecorator in event-handler-core),\n // before the router dispatches — so they cover every route, not just GraphQL. Their side-\n // effects are container registrations, which persist and are resolvable here.\n\n // Run contextual schemas BEFORE composer.build() so that any CoreGraphQLSchemaFactory\n // registrations they make (e.g. ACO folder schema plugins) are picked up by GraphQLSchemaComposer.\n const extraSchemas = await this.buildContextualSchemas(ctx);\n\n const schemaConfig = await this.composer.build(ctx);\n\n const resolverDecoration = new ResolverDecoration();\n if (schemaConfig.resolverDecorators) {\n resolverDecoration.addDecorators(schemaConfig.resolverDecorators);\n }\n\n // Always provide base root types so that `extend type Query/Mutation` works without\n // requiring callers to define them. With assumeValidSDL:true, empty base types are\n // allowed at build time; graphql() then returns schema-validation errors at execution\n // time (e.g. \"Type Query must define one or more fields.\") when no fields are registered.\n const typeDefs = `type Query\\ntype Mutation\\n${schemaConfig.typeDefs ?? \"\"}`;\n const staticSchema = makeExecutableSchema({\n typeDefs,\n resolvers: resolverDecoration.decorateResolvers(\n mergeResolvers([schemaConfig.resolvers ?? {}])\n ),\n assumeValidSDL: true,\n inheritResolversFromInterfaces: true\n });\n\n const schema = await this.buildSchema(staticSchema, extraSchemas);\n const parsed = createRequestBody(body);\n\n if (!Array.isArray(parsed)) {\n return this.executeOne(parsed, schema, ctx);\n }\n // Run sequentially so per-request state (e.g. ctx.debug.logs) is scoped per query.\n const results = [];\n for (const b of parsed) {\n results.push(await this.executeOne(b, schema, ctx));\n }\n return results;\n }\n\n private async buildContext(): Promise<Record<string, any>> {\n const ctx: Record<string, any> = { container: this.container };\n for (const enhancer of this.enhancers) {\n await enhancer.enhance(ctx);\n }\n return ctx;\n }\n\n private async buildContextualSchemas(ctx: Record<string, any>): Promise<GraphQLSchema[]> {\n if (this.contextualSchemas.length === 0) {\n return [];\n }\n // Sequential — schemas may have ordering dependencies (e.g. Aco needs ctx.cms from HeadlessCms).\n const schemas: GraphQLSchema[] = [];\n for (const s of this.contextualSchemas) {\n schemas.push(await s.build(ctx));\n }\n return schemas;\n }\n\n private async buildSchema(\n staticSchema: GraphQLSchema,\n extraSchemas: GraphQLSchema[]\n ): Promise<GraphQLSchema> {\n if (extraSchemas.length === 0) {\n return staticSchema;\n }\n return mergeSchemas({ schemas: [staticSchema, ...extraSchemas] });\n }\n\n private async executeOne(\n body: GraphQLRequestBody,\n schema: GraphQLSchema,\n ctx: Record<string, any>\n ): Promise<any> {\n const { query, variables, operationName } = body;\n\n return graphql({\n schema,\n source: query,\n rootValue: {},\n contextValue: ctx,\n variableValues: variables ?? undefined,\n operationName: operationName ?? undefined\n });\n }\n}\n\nexport const GraphQLEngine = GraphQLEngineAbstraction.createImplementation({\n implementation: GraphQLEngineImpl,\n dependencies: [\n GraphQLSchemaComposer,\n RequestContainer,\n [GraphQLContextEnhancer, { multiple: true }],\n [GraphQLContextualSchema, { multiple: true }]\n ]\n});\n"],"names":["GraphQLEngineImpl","composer","container","enhancers","contextualSchemas","body","ctx","extraSchemas","schemaConfig","resolverDecoration","ResolverDecoration","typeDefs","staticSchema","makeExecutableSchema","mergeResolvers","schema","parsed","createRequestBody","Array","results","b","enhancer","schemas","s","mergeSchemas","query","variables","operationName","graphql","undefined","GraphQLEngine","GraphQLEngineAbstraction","GraphQLSchemaComposer","RequestContainer","GraphQLContextEnhancer","GraphQLContextualSchema"],"mappings":";;;;;;;;;;AAiBA,MAAMA;IACF,YACYC,QAAgC,EAChCC,SAAoB,EACpBC,SAAoC,EACpCC,iBAA6C,CACvD;aAJUH,QAAQ,GAARA;aACAC,SAAS,GAATA;aACAC,SAAS,GAATA;aACAC,iBAAiB,GAAjBA;IACT;IAEH,MAAM,QAAQC,IAAS,EAAgB;QAEnC,MAAMC,MAAM,MAAM,IAAI,CAAC,YAAY;QASnC,MAAMC,eAAe,MAAM,IAAI,CAAC,sBAAsB,CAACD;QAEvD,MAAME,eAAe,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAACF;QAE/C,MAAMG,qBAAqB,IAAIC;QAC/B,IAAIF,aAAa,kBAAkB,EAC/BC,mBAAmB,aAAa,CAACD,aAAa,kBAAkB;QAOpE,MAAMG,WAAW,CAAC,2BAA2B,EAAEH,aAAa,QAAQ,IAAI,IAAI;QAC5E,MAAMI,eAAeC,qBAAqB;YACtCF;YACA,WAAWF,mBAAmB,iBAAiB,CAC3CK,eAAe;gBAACN,aAAa,SAAS,IAAI,CAAC;aAAE;YAEjD,gBAAgB;YAChB,gCAAgC;QACpC;QAEA,MAAMO,SAAS,MAAM,IAAI,CAAC,WAAW,CAACH,cAAcL;QACpD,MAAMS,S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SAAE;QAC5C;YAACC;YAAyB;gBAAE,UAAU;YAAK;SAAE;KAChD;AACL"}
1
+ {"version":3,"file":"engine/GraphQLEngine.js","sources":["../../src/engine/GraphQLEngine.ts"],"sourcesContent":["import { graphql } from \"graphql\";\nimport { makeExecutableSchema, mergeSchemas } from \"@graphql-tools/schema\";\nimport { mergeResolvers } from \"@graphql-tools/merge\";\nimport { Container } from \"@webiny/di\";\nimport { RequestContainer } from \"@webiny/event-handler-core\";\nimport { GraphQLEngine as GraphQLEngineAbstraction } from \"./abstractions.js\";\nimport { GraphQLContextEnhancer } from \"./GraphQLContextEnhancer.js\";\nimport { GraphQLContextualSchema } from \"./GraphQLContextualSchema.js\";\nimport { GraphQLSchemaComposer } from \"~/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { ResolverDecoration } from \"~/ResolverDecoration.js\";\nimport { createRequestBody } from \"~/createRequestBody.js\";\nimport type { IGraphQLSchemaComposer } from \"~/features/GraphQLSchemaBuilder/abstractions.js\";\nimport type { IGraphQLContextEnhancer } from \"./GraphQLContextEnhancer.js\";\nimport type { IGraphQLContextualSchema } from \"./GraphQLContextualSchema.js\";\nimport type { GraphQLRequestBody } from \"~/types.js\";\nimport type { GraphQLSchema } from \"graphql\";\n\nclass GraphQLEngineImpl implements GraphQLEngineAbstraction.Interface {\n constructor(\n private composer: IGraphQLSchemaComposer,\n private container: Container,\n private enhancers: IGraphQLContextEnhancer[],\n private contextualSchemas: IGraphQLContextualSchema[]\n ) {}\n\n async execute(body: any): Promise<any> {\n // Build context first — enhancers may be async (e.g. CMS storage init)\n const ctx = await this.buildContext();\n\n // Run contextual schemas BEFORE composer.build() so that any CoreGraphQLSchemaFactory\n // registrations they make (e.g. ACO folder schema plugins) are picked up by GraphQLSchemaComposer.\n const extraSchemas = await this.buildContextualSchemas(ctx);\n\n const schemaConfig = await this.composer.build(ctx);\n\n const resolverDecoration = new ResolverDecoration();\n if (schemaConfig.resolverDecorators) {\n resolverDecoration.addDecorators(schemaConfig.resolverDecorators);\n }\n\n // Always provide base root types so that `extend type Query/Mutation` works without\n // requiring callers to define them. With assumeValidSDL:true, empty base types are\n // allowed at build time; graphql() then returns schema-validation errors at execution\n // time (e.g. \"Type Query must define one or more fields.\") when no fields are registered.\n const typeDefs = `type Query\\ntype Mutation\\n${schemaConfig.typeDefs ?? \"\"}`;\n const staticSchema = makeExecutableSchema({\n typeDefs,\n resolvers: resolverDecoration.decorateResolvers(\n mergeResolvers([schemaConfig.resolvers ?? {}])\n ),\n assumeValidSDL: true,\n inheritResolversFromInterfaces: true\n });\n\n const schema = await this.buildSchema(staticSchema, extraSchemas);\n const parsed = createRequestBody(body);\n\n if (!Array.isArray(parsed)) {\n return this.executeOne(parsed, schema, ctx);\n }\n // Run sequentially so per-request state (e.g. ctx.debug.logs) is scoped per query.\n const results = [];\n for (const b of parsed) {\n results.push(await this.executeOne(b, schema, ctx));\n }\n return results;\n }\n\n private async buildContext(): Promise<Record<string, any>> {\n const ctx: Record<string, any> = { container: this.container };\n for (const enhancer of this.enhancers) {\n await enhancer.enhance(ctx);\n }\n return ctx;\n }\n\n private async buildContextualSchemas(ctx: Record<string, any>): Promise<GraphQLSchema[]> {\n if (this.contextualSchemas.length === 0) {\n return [];\n }\n // Sequential — schemas may have ordering dependencies (e.g. Aco needs ctx.cms from HeadlessCms).\n const schemas: GraphQLSchema[] = [];\n for (const s of this.contextualSchemas) {\n schemas.push(await s.build(ctx));\n }\n return schemas;\n }\n\n private async buildSchema(\n staticSchema: GraphQLSchema,\n extraSchemas: GraphQLSchema[]\n ): Promise<GraphQLSchema> {\n if (extraSchemas.length === 0) {\n return staticSchema;\n }\n return mergeSchemas({ schemas: [staticSchema, ...extraSchemas] });\n }\n\n private async executeOne(\n body: GraphQLRequestBody,\n schema: GraphQLSchema,\n ctx: Record<string, any>\n ): Promise<any> {\n const { query, variables, operationName } = body;\n\n return graphql({\n schema,\n source: query,\n rootValue: {},\n contextValue: ctx,\n variableValues: variables ?? undefined,\n operationName: operationName ?? undefined\n });\n }\n}\n\nexport const GraphQLEngine = GraphQLEngineAbstraction.createImplementation({\n implementation: GraphQLEngineImpl,\n dependencies: [\n GraphQLSchemaComposer,\n RequestContainer,\n [GraphQLContextEnhancer, { multiple: true }],\n [GraphQLContextualSchema, { multiple: true }]\n ]\n});\n"],"names":["GraphQLEngineImpl","composer","container","enhancers","contextualSchemas","body","ctx","extraSchemas","schemaConfig","resolverDecoration","ResolverDecoration","typeDefs","staticSchema","makeExecutableSchema","mergeResolvers","schema","parsed","createRequestBody","Array","results","b","enhancer","schemas","s","mergeSchemas","query","variables","operationName","graphql","undefined","GraphQLEngine","GraphQLEngineAbstraction","GraphQLSchemaComposer","RequestContainer","GraphQLContextEnhancer","GraphQLContextualSchema"],"mappings":";;;;;;;;;;AAiBA,MAAMA;IACF,YACYC,QAAgC,EAChCC,SAAoB,EACpBC,SAAoC,EACpCC,iBAA6C,CACvD;aAJUH,QAAQ,GAARA;aACAC,SAAS,GAATA;aACAC,SAAS,GAATA;aACAC,iBAAiB,GAAjBA;IACT;IAEH,MAAM,QAAQC,IAAS,EAAgB;QAEnC,MAAMC,MAAM,MAAM,IAAI,CAAC,YAAY;QAInC,MAAMC,eAAe,MAAM,IAAI,CAAC,sBAAsB,CAACD;QAEvD,MAAME,eAAe,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAACF;QAE/C,MAAMG,qBAAqB,IAAIC;QAC/B,IAAIF,aAAa,kBAAkB,EAC/BC,mBAAmB,aAAa,CAACD,aAAa,kBAAkB;QAOpE,MAAMG,WAAW,CAAC,2BAA2B,EAAEH,aAAa,QAAQ,IAAI,IAAI;QAC5E,MAAMI,eAAeC,qBAAqB;YACtCF;YACA,WAAWF,mBAAmB,iBAAiB,CAC3CK,eAAe;gBAACN,aAAa,SAAS,IAAI,CAAC;aAAE;YAEjD,gBAAgB;YAChB,gCAAgC;QACpC;QAEA,MAAMO,SAAS,MAAM,IAAI,CAAC,WAAW,CAACH,cAAcL;QACpD,MAAM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AK;SAAE;QAC5C;YAACC;YAAyB;gBAAE,UAAU;YAAK;SAAE;KAChD;AACL"}
@@ -1,13 +1,13 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { GraphQLSchemaComposerFeature } from "../features/GraphQLSchemaBuilder/feature.js";
3
3
  import { GraphQLEngine } from "./GraphQLEngine.js";
4
- import { GraphQLRoute } from "./GraphQLRoute.js";
4
+ import { GraphQLRouteDefinition } from "./GraphQLRoute.js";
5
5
  const GraphQLEngineFeature = createFeature({
6
6
  name: "GraphQLEngine",
7
7
  register (container) {
8
8
  GraphQLSchemaComposerFeature.register(container);
9
9
  container.register(GraphQLEngine);
10
- container.register(GraphQLRoute);
10
+ container.register(GraphQLRouteDefinition);
11
11
  }
12
12
  });
13
13
  export { GraphQLEngineFeature };
@@ -1 +1 @@
1
- {"version":3,"file":"engine/GraphQLEngineFeature.js","sources":["../../src/engine/GraphQLEngineFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { GraphQLSchemaComposerFeature } from \"~/features/GraphQLSchemaBuilder/feature.js\";\nimport { GraphQLEngine } from \"./GraphQLEngine.js\";\nimport { GraphQLRoute } from \"./GraphQLRoute.js\";\n\nexport const GraphQLEngineFeature = createFeature({\n name: \"GraphQLEngine\",\n register(container) {\n GraphQLSchemaComposerFeature.register(container);\n container.register(GraphQLEngine);\n container.register(GraphQLRoute);\n }\n});\n"],"names":["GraphQLEngineFeature","createFeature","container","GraphQLSchemaComposerFeature","GraphQLEngine","GraphQLRoute"],"mappings":";;;;AAKO,MAAMA,uBAAuBC,cAAc;IAC9C,MAAM;IACN,UAASC,SAAS;QACdC,6BAA6B,QAAQ,CAACD;QACtCA,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;IACvB;AACJ"}
1
+ {"version":3,"file":"engine/GraphQLEngineFeature.js","sources":["../../src/engine/GraphQLEngineFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\n\nimport { GraphQLSchemaComposerFeature } from \"~/features/GraphQLSchemaBuilder/feature.js\";\nimport { GraphQLEngine } from \"./GraphQLEngine.js\";\nimport { GraphQLRouteDefinition } from \"./GraphQLRoute.js\";\n\nexport const GraphQLEngineFeature = createFeature({\n name: \"GraphQLEngine\",\n register(container) {\n GraphQLSchemaComposerFeature.register(container);\n container.register(GraphQLEngine);\n container.register(GraphQLRouteDefinition);\n }\n});\n"],"names":["GraphQLEngineFeature","createFeature","container","GraphQLSchemaComposerFeature","GraphQLEngine","GraphQLRouteDefinition"],"mappings":";;;;AAMO,MAAMA,uBAAuBC,cAAc;IAC9C,MAAM;IACN,UAASC,SAAS;QACdC,6BAA6B,QAAQ,CAACD;QACtCA,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;IACvB;AACJ"}
@@ -1,14 +1,24 @@
1
- import { HttpRoute } from "@webiny/event-handler-core";
1
+ import { HttpRouteDefinition, HttpRouteHandler } from "@webiny/event-handler-core";
2
2
  import type { IHttpRequest, IHttpResponse } from "@webiny/event-handler-core";
3
3
  import type { IGraphQLEngine } from "./abstractions.js";
4
- declare class GraphQLRouteImpl implements HttpRoute.Interface {
4
+ declare class GraphQLRouteImpl implements HttpRouteHandler.Interface {
5
5
  private engine;
6
- readonly method = "POST";
7
- readonly path = "/graphql";
8
6
  constructor(engine: IGraphQLEngine);
9
7
  handle(request: IHttpRequest): Promise<IHttpResponse>;
10
8
  }
11
9
  export declare const GraphQLRoute: typeof GraphQLRouteImpl & {
12
10
  __abstraction: import("@webiny/di").Abstraction<import("@webiny/event-handler-core").IHttpRoute>;
13
11
  };
12
+ declare class GraphQLRouteDefinitionImpl implements HttpRouteDefinition.Interface {
13
+ readonly name = "graphql";
14
+ readonly method = "POST";
15
+ readonly path = "/graphql";
16
+ readonly handler: typeof GraphQLRouteImpl & {
17
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/event-handler-core").IHttpRoute>;
18
+ };
19
+ }
20
+ /** What the router matches on. Zero dependencies, so building it costs nothing. */
21
+ export declare const GraphQLRouteDefinition: typeof GraphQLRouteDefinitionImpl & {
22
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/event-handler-core").IHttpRouteDefinition>;
23
+ };
14
24
  export {};
@@ -1,10 +1,8 @@
1
- import { HttpRoute } from "@webiny/event-handler-core";
1
+ import { HttpRouteDefinition, HttpRouteHandler } from "@webiny/event-handler-core";
2
2
  import { GraphQLEngine } from "./abstractions.js";
3
3
  class GraphQLRouteImpl {
4
4
  constructor(engine){
5
5
  this.engine = engine;
6
- this.method = "POST";
7
- this.path = "/graphql";
8
6
  }
9
7
  async handle(request) {
10
8
  const result = await this.engine.execute(request.body);
@@ -17,12 +15,24 @@ class GraphQLRouteImpl {
17
15
  };
18
16
  }
19
17
  }
20
- const GraphQLRoute = HttpRoute.createImplementation({
18
+ const GraphQLRoute = HttpRouteHandler.createImplementation({
21
19
  implementation: GraphQLRouteImpl,
22
20
  dependencies: [
23
21
  GraphQLEngine
24
22
  ]
25
23
  });
26
- export { GraphQLRoute };
24
+ class GraphQLRouteDefinitionImpl {
25
+ constructor(){
26
+ this.name = "graphql";
27
+ this.method = "POST";
28
+ this.path = "/graphql";
29
+ this.handler = GraphQLRoute;
30
+ }
31
+ }
32
+ const GraphQLRouteDefinition = HttpRouteDefinition.createImplementation({
33
+ implementation: GraphQLRouteDefinitionImpl,
34
+ dependencies: []
35
+ });
36
+ export { GraphQLRoute, GraphQLRouteDefinition };
27
37
 
28
38
  //# sourceMappingURL=GraphQLRoute.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine/GraphQLRoute.js","sources":["../../src/engine/GraphQLRoute.ts"],"sourcesContent":["import { HttpRoute } from \"@webiny/event-handler-core\";\nimport { GraphQLEngine } from \"./abstractions.js\";\nimport type { IHttpRequest, IHttpResponse } from \"@webiny/event-handler-core\";\nimport type { IGraphQLEngine } from \"./abstractions.js\";\n\nclass GraphQLRouteImpl implements HttpRoute.Interface {\n readonly method = \"POST\";\n readonly path = \"/graphql\";\n\n constructor(private engine: IGraphQLEngine) {}\n\n async handle(request: IHttpRequest): Promise<IHttpResponse> {\n const result = await this.engine.execute(request.body);\n return {\n statusCode: 200,\n headers: { \"Content-Type\": \"application/json\" },\n body: result\n };\n }\n}\n\nexport const GraphQLRoute = HttpRoute.createImplementation({\n implementation: GraphQLRouteImpl,\n dependencies: [GraphQLEngine]\n});\n"],"names":["GraphQLRouteImpl","engine","request","result","GraphQLRoute","HttpRoute","GraphQLEngine"],"mappings":";;AAKA,MAAMA;IAIF,YAAoBC,MAAsB,CAAE;aAAxBA,MAAM,GAANA;aAHX,MAAM,GAAG;aACT,IAAI,GAAG;IAE6B;IAE7C,MAAM,OAAOC,OAAqB,EAA0B;QACxD,MAAMC,SAAS,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAACD,QAAQ,IAAI;QACrD,OAAO;YACH,YAAY;YACZ,SAAS;gBAAE,gBAAgB;YAAmB;YAC9C,MAAMC;QACV;IACJ;AACJ;AAEO,MAAMC,eAAeC,UAAU,oBAAoB,CAAC;IACvD,gBAAgBL;IAChB,cAAc;QAACM;KAAc;AACjC"}
1
+ {"version":3,"file":"engine/GraphQLRoute.js","sources":["../../src/engine/GraphQLRoute.ts"],"sourcesContent":["import { HttpRouteDefinition, HttpRouteHandler } from \"@webiny/event-handler-core\";\nimport { GraphQLEngine } from \"./abstractions.js\";\nimport type { IHttpRequest, IHttpResponse } from \"@webiny/event-handler-core\";\nimport type { IGraphQLEngine } from \"./abstractions.js\";\n\nclass GraphQLRouteImpl implements HttpRouteHandler.Interface {\n constructor(private engine: IGraphQLEngine) {}\n\n async handle(request: IHttpRequest): Promise<IHttpResponse> {\n const result = await this.engine.execute(request.body);\n return {\n statusCode: 200,\n headers: { \"Content-Type\": \"application/json\" },\n body: result\n };\n }\n}\n\nexport const GraphQLRoute = HttpRouteHandler.createImplementation({\n implementation: GraphQLRouteImpl,\n dependencies: [GraphQLEngine]\n});\n\nclass GraphQLRouteDefinitionImpl implements HttpRouteDefinition.Interface {\n readonly name = \"graphql\";\n readonly method = \"POST\";\n readonly path = \"/graphql\";\n readonly handler = GraphQLRoute;\n}\n\n/** What the router matches on. Zero dependencies, so building it costs nothing. */\nexport const GraphQLRouteDefinition = HttpRouteDefinition.createImplementation({\n implementation: GraphQLRouteDefinitionImpl,\n dependencies: []\n});\n"],"names":["GraphQLRouteImpl","engine","request","result","GraphQLRoute","HttpRouteHandler","GraphQLEngine","GraphQLRouteDefinitionImpl","GraphQLRouteDefinition","HttpRouteDefinition"],"mappings":";;AAKA,MAAMA;IACF,YAAoBC,MAAsB,CAAE;aAAxBA,MAAM,GAANA;IAAyB;IAE7C,MAAM,OAAOC,OAAqB,EAA0B;QACxD,MAAMC,SAAS,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAACD,QAAQ,IAAI;QACrD,OAAO;YACH,YAAY;YACZ,SAAS;gBAAE,gBAAgB;YAAmB;YAC9C,MAAMC;QACV;IACJ;AACJ;AAEO,MAAMC,eAAeC,iBAAiB,oBAAoB,CAAC;IAC9D,gBAAgBL;IAChB,cAAc;QAACM;KAAc;AACjC;AAEA,MAAMC;;aACO,IAAI,GAAG;aACP,MAAM,GAAG;aACT,IAAI,GAAG;aACP,OAAO,GAAGH;;AACvB;AAGO,MAAMI,yBAAyBC,oBAAoB,oBAAoB,CAAC;IAC3E,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-graphql",
3
- "version": "6.6.0-alpha.0",
3
+ "version": "6.6.0-alpha.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -18,27 +18,27 @@
18
18
  "Adrian Smijulj <adrian@webiny.com>"
19
19
  ],
20
20
  "dependencies": {
21
- "@graphql-tools/merge": "9.2.2",
22
- "@graphql-tools/resolvers-composition": "7.0.35",
23
- "@graphql-tools/schema": "10.0.38",
24
- "@graphql-tools/utils": "11.2.2",
25
- "@webiny/api": "6.6.0-alpha.0",
26
- "@webiny/di": "1.0.2",
27
- "@webiny/error": "6.6.0-alpha.0",
28
- "@webiny/event-handler-core": "6.6.0-alpha.0",
29
- "@webiny/feature": "6.6.0-alpha.0",
30
- "@webiny/handler": "6.6.0-alpha.0",
31
- "@webiny/plugins": "6.6.0-alpha.0",
32
- "@webiny/utils": "6.6.0-alpha.0",
21
+ "@graphql-tools/merge": "9.2.3",
22
+ "@graphql-tools/resolvers-composition": "7.0.36",
23
+ "@graphql-tools/schema": "10.1.0",
24
+ "@graphql-tools/utils": "12.0.0",
25
+ "@webiny/api": "6.6.0-alpha.2",
26
+ "@webiny/di": "1.1.0",
27
+ "@webiny/error": "6.6.0-alpha.2",
28
+ "@webiny/event-handler-core": "6.6.0-alpha.2",
29
+ "@webiny/feature": "6.6.0-alpha.2",
30
+ "@webiny/handler": "6.6.0-alpha.2",
31
+ "@webiny/plugins": "6.6.0-alpha.2",
32
+ "@webiny/utils": "6.6.0-alpha.2",
33
33
  "graphql": "16.14.2",
34
- "graphql-scalars": "1.25.0",
34
+ "graphql-scalars": "2.0.0",
35
35
  "zod": "4.4.3"
36
36
  },
37
37
  "devDependencies": {
38
- "@webiny/build-tools": "6.6.0-alpha.0",
38
+ "@webiny/build-tools": "6.6.0-alpha.2",
39
39
  "rimraf": "6.1.3",
40
40
  "typescript": "7.0.2",
41
- "vitest": "4.1.10"
41
+ "vitest": "4.1.11"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public"
@@ -1 +1 @@
1
- {"version":3,"file":"registerLegacyPluginsViaGqlContextEnhancer.js","sources":["../src/registerLegacyPluginsViaGqlContextEnhancer.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { GraphQLContextEnhancer } from \"./engine/index.js\";\nimport type { IGraphQLContextEnhancer } from \"./engine/index.js\";\n\n/**\n * Escape hatch for legacy plugin-based code that hasn't been migrated to createFeature() yet.\n *\n * Accepts any plugin array (same shape as the old createHandler({ plugins: [...] })) and\n * applies them via a GraphQLContextEnhancer so they still receive the context object.\n *\n * Usage in createLambdaHandler request callback:\n * registerLegacyPluginsViaGqlContextEnhancer(container, extensions());\n * registerLegacyPluginsViaGqlContextEnhancer(container, [myPlugin(), anotherPlugin()]);\n */\nexport function registerLegacyPluginsViaGqlContextEnhancer(\n container: Container,\n plugins: any | any[]\n): void {\n const flat = [plugins].flat(Infinity as 1).filter(Boolean);\n let initialized = false;\n\n const enhancer: IGraphQLContextEnhancer = {\n async enhance(ctx: Record<string, any>): Promise<void> {\n if (initialized) {\n return;\n }\n initialized = true;\n\n // Legacy plugins assume ctx.plugins exists (they call ctx.plugins.register() directly).\n // Mirror the contract of the old createHandler which always initialised PluginsContainer.\n if (!ctx.plugins) {\n ctx.plugins = new PluginsContainer([]);\n }\n\n for (const plugin of flat) {\n if (typeof plugin.apply === \"function\") {\n await plugin.apply(ctx);\n } else if (ctx.plugins) {\n ctx.plugins.register(plugin);\n }\n }\n }\n };\n\n container.registerInstance(GraphQLContextEnhancer, enhancer);\n}\n"],"names":["registerLegacyPluginsViaGqlContextEnhancer","container","plugins","flat","Infinity","Boolean","initialized","enhancer","ctx","PluginsContainer","plugin","GraphQLContextEnhancer"],"mappings":";;AAeO,SAASA,2CACZC,SAAoB,EACpBC,OAAoB;IAEpB,MAAMC,OAAO;QAACD;KAAQ,CAAC,IAAI,CAACE,OAAe,MAAM,CAACC;IAClD,IAAIC,cAAc;IAElB,MAAMC,WAAoC;QACtC,MAAM,SAAQC,GAAwB;YAClC,IAAIF,aACA;YAEJA,cAAc;YAId,IAAI,CAACE,IAAI,OAAO,EACZA,IAAI,OAAO,GAAG,IAAIC,iBAAiB,EAAE;YAGzC,KAAK,MAAMC,UAAUP,KACjB,IAAI,AAAwB,cAAxB,OAAOO,OAAO,KAAK,EACnB,MAAMA,OAAO,KAAK,CAACF;iBAChB,IAAIA,IAAI,OAAO,EAClBA,IAAI,OAAO,CAAC,QAAQ,CAACE;QAGjC;IACJ;IAEAT,UAAU,gBAAgB,CAACU,wBAAwBJ;AACvD"}
1
+ {"version":3,"file":"registerLegacyPluginsViaGqlContextEnhancer.js","sources":["../src/registerLegacyPluginsViaGqlContextEnhancer.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { GraphQLContextEnhancer } from \"./engine/index.js\";\nimport type { IGraphQLContextEnhancer } from \"./engine/index.js\";\n\n/**\n * Escape hatch for legacy plugin-based code that hasn't been migrated to createFeature() yet.\n *\n * Accepts any plugin array (same shape as the old createHandler({ plugins: [...] })) and\n * applies them via a GraphQLContextEnhancer so they still receive the context object.\n *\n * Usage in createLambdaHandler request callback:\n * registerLegacyPluginsViaGqlContextEnhancer(container, extensions());\n * registerLegacyPluginsViaGqlContextEnhancer(container, [myPlugin(), anotherPlugin()]);\n */\nexport function registerLegacyPluginsViaGqlContextEnhancer(\n container: Container,\n plugins: any | any[]\n): void {\n const flat = [plugins].flat(Infinity as 1).filter(Boolean);\n let initialized = false;\n\n const enhancer: IGraphQLContextEnhancer = {\n async enhance(ctx: Record<string, any>): Promise<void> {\n if (initialized) {\n return;\n }\n initialized = true;\n\n // Legacy plugins assume ctx.plugins exists (they call ctx.plugins.register() directly).\n // Mirror the contract of the old createHandler which always initialised PluginsContainer.\n if (!ctx.plugins) {\n ctx.plugins = new PluginsContainer([]);\n }\n\n for (const plugin of flat) {\n if (typeof plugin.apply === \"function\") {\n await plugin.apply(ctx);\n } else if (ctx.plugins) {\n ctx.plugins.register(plugin);\n }\n }\n }\n };\n\n container.registerInstance(GraphQLContextEnhancer, enhancer);\n}\n"],"names":["registerLegacyPluginsViaGqlContextEnhancer","container","plugins","flat","Infinity","Boolean","initialized","enhancer","ctx","PluginsContainer","plugin","GraphQLContextEnhancer"],"mappings":";;AAeO,SAASA,2CACZC,SAAoB,EACpBC,OAAoB;IAEpB,MAAMC,OAAO;QAACD;KAAQ,CAAC,IAAI,CAACE,KAAQ,EAAO,MAAM,CAACC;IAClD,IAAIC,cAAc;IAElB,MAAMC,WAAoC;QACtC,MAAM,SAAQC,GAAwB;YAClC,IAAIF,aACA;YAEJA,cAAc;YAId,IAAI,CAACE,IAAI,OAAO,EACZA,IAAI,OAAO,GAAG,IAAIC,iBAAiB,EAAE;YAGzC,KAAK,MAAMC,UAAUP,KACjB,IAAI,AAAwB,cAAxB,OAAOO,OAAO,KAAK,EACnB,MAAMA,OAAO,KAAK,CAACF;iBAChB,IAAIA,IAAI,OAAO,EAClBA,IAAI,OAAO,CAAC,QAAQ,CAACE;QAGjC;IACJ;IAEAT,UAAU,gBAAgB,CAACU,wBAAwBJ;AACvD"}