@webiny/handler-graphql 6.0.0-alpha.0 → 6.0.0-alpha.1
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/ResolverDecoration.d.ts +1 -1
- package/ResolverDecoration.js.map +1 -1
- package/createGraphQLHandler.d.ts +2 -2
- package/createGraphQLHandler.js.map +1 -1
- package/createGraphQLSchema.d.ts +2 -2
- package/createGraphQLSchema.js.map +1 -1
- package/createResolverDecorator.d.ts +1 -1
- package/createResolverDecorator.js.map +1 -1
- package/debugPlugins.d.ts +2 -2
- package/debugPlugins.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js.map +1 -1
- package/package.json +8 -8
- package/plugins/GraphQLSchemaPlugin.d.ts +2 -2
- package/plugins/GraphQLSchemaPlugin.js.map +1 -1
- package/processRequestBody.d.ts +1 -1
- package/processRequestBody.js.map +1 -1
- package/types.d.ts +6 -6
- package/types.js.map +1 -1
- package/utils/resolve.d.ts +1 -1
- package/utils/resolve.js.map +1 -1
package/ResolverDecoration.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_resolversComposition","require","ResolverDecoration","decorators","addDecorators","resolverDecorators","key","existingDecorators","decorateResolvers","resolvers","composeResolvers","exports"],"sources":["ResolverDecoration.ts"],"sourcesContent":["import { composeResolvers } from \"@graphql-tools/resolvers-composition\";\nimport { ResolverDecorators, Resolvers } from \"./types\";\n\nexport class ResolverDecoration {\n private decorators: ResolverDecorators = {};\n\n addDecorators(resolverDecorators: ResolverDecorators) {\n for (const key in resolverDecorators) {\n const decorators = resolverDecorators[key];\n if (!decorators) {\n continue;\n }\n\n const existingDecorators = this.decorators[key] ?? [];\n this.decorators[key] = [...existingDecorators, ...decorators];\n }\n }\n\n decorateResolvers(resolvers: Resolvers<unknown>) {\n return composeResolvers(resolvers, this.decorators);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAGO,MAAMC,kBAAkB,CAAC;EACpBC,UAAU,GAAuB,CAAC,CAAC;EAE3CC,aAAaA,CAACC,kBAAsC,EAAE;IAClD,KAAK,MAAMC,GAAG,IAAID,kBAAkB,EAAE;MAClC,MAAMF,UAAU,GAAGE,kBAAkB,CAACC,GAAG,CAAC;MAC1C,IAAI,CAACH,UAAU,EAAE;QACb;MACJ;MAEA,MAAMI,kBAAkB,GAAG,IAAI,CAACJ,UAAU,CAACG,GAAG,CAAC,IAAI,EAAE;MACrD,IAAI,CAACH,UAAU,CAACG,GAAG,CAAC,GAAG,CAAC,GAAGC,kBAAkB,EAAE,GAAGJ,UAAU,CAAC;IACjE;EACJ;EAEAK,iBAAiBA,CAACC,SAA6B,EAAE;IAC7C,OAAO,IAAAC,sCAAgB,EAACD,SAAS,EAAE,IAAI,CAACN,UAAU,CAAC;EACvD;AACJ;AAACQ,OAAA,CAAAT,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_resolversComposition","require","ResolverDecoration","decorators","addDecorators","resolverDecorators","key","existingDecorators","decorateResolvers","resolvers","composeResolvers","exports"],"sources":["ResolverDecoration.ts"],"sourcesContent":["import { composeResolvers } from \"@graphql-tools/resolvers-composition\";\nimport type { ResolverDecorators, Resolvers } from \"./types\";\n\nexport class ResolverDecoration {\n private decorators: ResolverDecorators = {};\n\n addDecorators(resolverDecorators: ResolverDecorators) {\n for (const key in resolverDecorators) {\n const decorators = resolverDecorators[key];\n if (!decorators) {\n continue;\n }\n\n const existingDecorators = this.decorators[key] ?? [];\n this.decorators[key] = [...existingDecorators, ...decorators];\n }\n }\n\n decorateResolvers(resolvers: Resolvers<unknown>) {\n return composeResolvers(resolvers, this.decorators);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAGO,MAAMC,kBAAkB,CAAC;EACpBC,UAAU,GAAuB,CAAC,CAAC;EAE3CC,aAAaA,CAACC,kBAAsC,EAAE;IAClD,KAAK,MAAMC,GAAG,IAAID,kBAAkB,EAAE;MAClC,MAAMF,UAAU,GAAGE,kBAAkB,CAACC,GAAG,CAAC;MAC1C,IAAI,CAACH,UAAU,EAAE;QACb;MACJ;MAEA,MAAMI,kBAAkB,GAAG,IAAI,CAACJ,UAAU,CAACG,GAAG,CAAC,IAAI,EAAE;MACrD,IAAI,CAACH,UAAU,CAACG,GAAG,CAAC,GAAG,CAAC,GAAGC,kBAAkB,EAAE,GAAGJ,UAAU,CAAC;IACjE;EACJ;EAEAK,iBAAiBA,CAACC,SAA6B,EAAE;IAC7C,OAAO,IAAAC,sCAAgB,EAACD,SAAS,EAAE,IAAI,CAACN,UAAU,CAAC;EACvD;AACJ;AAACQ,OAAA,CAAAT,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins/types";
|
|
2
|
-
import { HandlerGraphQLOptions } from "./types";
|
|
1
|
+
import type { Plugin } from "@webiny/plugins/types";
|
|
2
|
+
import type { HandlerGraphQLOptions } from "./types";
|
|
3
3
|
declare const _default: (options?: HandlerGraphQLOptions) => Plugin[];
|
|
4
4
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_boolean","require","_handler","_error","_interopRequireDefault","_createGraphQLSchema","_debugPlugins","_processRequestBody","DEFAULT_CACHE_MAX_AGE","createCacheKey","context","plugins","getSchemaPlugins","tenant","tenancy","getCurrentTenant","contentLocale","i18n","getContentLocale","id","code","length","toString","filter","Boolean","join","createRequestBody","body","JSON","parse","formatErrorPayload","error","WebinyError","stringify","type","message","data","name","stack","_default","options","schema","undefined","cacheKey","debug","boolean","path","route","RoutePlugin","onPost","onOptions","_","reply","status","headers","send","hijack","request","contextCacheKey","createGraphQLSchema","ex","console","result","processRequestBody","sent","warn","debugPlugins","exports","default"],"sources":["createGraphQLHandler.ts"],"sourcesContent":["import { boolean } from \"boolean\";\nimport { GraphQLSchema } from \"graphql\";\nimport { Context
|
|
1
|
+
{"version":3,"names":["_boolean","require","_handler","_error","_interopRequireDefault","_createGraphQLSchema","_debugPlugins","_processRequestBody","DEFAULT_CACHE_MAX_AGE","createCacheKey","context","plugins","getSchemaPlugins","tenant","tenancy","getCurrentTenant","contentLocale","i18n","getContentLocale","id","code","length","toString","filter","Boolean","join","createRequestBody","body","JSON","parse","formatErrorPayload","error","WebinyError","stringify","type","message","data","name","stack","_default","options","schema","undefined","cacheKey","debug","boolean","path","route","RoutePlugin","onPost","onOptions","_","reply","status","headers","send","hijack","request","contextCacheKey","createGraphQLSchema","ex","console","result","processRequestBody","sent","warn","debugPlugins","exports","default"],"sources":["createGraphQLHandler.ts"],"sourcesContent":["import { boolean } from \"boolean\";\nimport type { GraphQLSchema } from \"graphql\";\nimport type { Context } from \"@webiny/handler\";\nimport { RoutePlugin } from \"@webiny/handler\";\nimport WebinyError from \"@webiny/error\";\nimport type { Plugin } from \"@webiny/plugins/types\";\nimport type { GraphQLRequestBody, HandlerGraphQLOptions } from \"./types\";\nimport { createGraphQLSchema, getSchemaPlugins } from \"./createGraphQLSchema\";\nimport debugPlugins from \"./debugPlugins\";\nimport { processRequestBody } from \"./processRequestBody\";\n\nconst DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year\n\nconst createCacheKey = (context: Context) => {\n const plugins = getSchemaPlugins(context);\n // TODO: in the near future, we have to assign a fixed name to every\n // TODO: GraphQLSchema plugin, to be able to create a reliable cache key.\n\n // TODO: `getCurrentTenant` should be injected as a parameter.\n // @ts-expect-error TODO: We should not be accessing `context` like this here.\n const tenant = context.tenancy?.getCurrentTenant();\n\n // TODO: `getContentLocale` should be injected as a parameter.\n // @ts-expect-error TODO: We should not be accessing `context` like this here.\n const contentLocale = context.i18n?.getContentLocale();\n\n return [\n tenant ? `tenant:${tenant.id}` : null,\n contentLocale ? `locale:${contentLocale.code}` : null,\n plugins.length.toString()\n ]\n .filter(Boolean)\n .join(\"#\");\n};\n\nconst createRequestBody = (body: unknown): GraphQLRequestBody | GraphQLRequestBody[] => {\n /**\n * We are trusting that the body payload is correct.\n * The `processRequestBody` will fail if it is not.\n */\n return typeof body === \"string\" ? JSON.parse(body) : body;\n};\n\nconst formatErrorPayload = (error: Error): string => {\n if (error instanceof WebinyError) {\n return JSON.stringify({\n type: \"CoreGraphQLWebinyError\",\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return JSON.stringify({\n type: \"Error\",\n name: error.name,\n message: error.message,\n stack: error.stack\n });\n};\n\nexport default (options: HandlerGraphQLOptions = {}): Plugin[] => {\n let schema: GraphQLSchema | undefined = undefined;\n let cacheKey: string | undefined = undefined;\n\n const debug = boolean(options.debug);\n\n const path = options?.path || \"/graphql\";\n\n const route = new RoutePlugin(async ({ onPost, onOptions, context }) => {\n onOptions(path, async (_, reply) => {\n return reply\n .status(204)\n .headers({\n \"Cache-Control\": `public, max-age=${DEFAULT_CACHE_MAX_AGE}`\n })\n .send({})\n .hijack();\n });\n onPost(path, async (request, reply) => {\n const contextCacheKey = createCacheKey(context as Context);\n if (!schema || cacheKey !== contextCacheKey) {\n try {\n schema = createGraphQLSchema(context);\n cacheKey = contextCacheKey;\n } catch (ex) {\n return reply.code(500).send(formatErrorPayload(ex));\n }\n }\n let body: GraphQLRequestBody | GraphQLRequestBody[];\n try {\n body = createRequestBody(request.body);\n } catch (ex) {\n console.error(`Error while creating the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n try {\n const result = await processRequestBody(body, schema, context);\n /**\n * IMPORTANT! Do not send anything if reply was already sent.\n */\n if (reply.sent) {\n console.warn(\"Reply already sent, cannot send the result (handler-graphql).\");\n return reply;\n }\n return reply.status(200).send(result);\n } catch (ex) {\n console.error(`Error while processing the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n });\n });\n\n route.name = \"handler.graphql.route.default\";\n\n return [\n ...(debug ? debugPlugins() : []),\n {\n type: \"wcp-telemetry-tracker\"\n },\n route\n ];\n};\n"],"mappings":";;;;;;;AAAA,IAA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CAACzB,kBAAkB,CAAC8B,EAAE,CAAC,CAAC;QACvD;MACJ;MACA,IAAIjC,IAA+C;MACnD,IAAI;QACAA,IAAI,GAAGD,iBAAiB,CAAC+B,OAAO,CAAC9B,IAAI,CAAC;MAC1C,CAAC,CAAC,OAAOiC,EAAE,EAAE;QACTC,OAAO,CAAC9B,KAAK,CAAC,wCAAwC,CAAC;QACvD8B,OAAO,CAAC9B,KAAK,CAACD,kBAAkB,CAAC8B,EAAE,CAAC,CAAC;QACrC,MAAMA,EAAE;MACZ;MACA,IAAI;QACA,MAAME,MAAM,GAAG,MAAM,IAAAC,sCAAkB,EAACpC,IAAI,EAAEc,MAAM,EAAE/B,OAAO,CAAC;QAC9D;AAChB;AACA;QACgB,IAAI0C,KAAK,CAACY,IAAI,EAAE;UACZH,OAAO,CAACI,IAAI,CAAC,+DAA+D,CAAC;UAC7E,OAAOb,KAAK;QAChB;QACA,OAAOA,KAAK,CAACC,MAAM,CAAC,GAAG,CAAC,CAACE,IAAI,CAACO,MAAM,CAAC;MACzC,CAAC,CAAC,OAAOF,EAAE,EAAE;QACTC,OAAO,CAAC9B,KAAK,CAAC,0CAA0C,CAAC;QACzD8B,OAAO,CAAC9B,KAAK,CAACD,kBAAkB,CAAC8B,EAAE,CAAC,CAAC;QACrC,MAAMA,EAAE;MACZ;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;EAEFb,KAAK,CAACV,IAAI,GAAG,+BAA+B;EAE5C,OAAO,CACH,IAAIO,KAAK,GAAG,IAAAsB,qBAAY,EAAC,CAAC,GAAG,EAAE,CAAC,EAChC;IACIhC,IAAI,EAAE;EACV,CAAC,EACDa,KAAK,CACR;AACL,CAAC;AAAAoB,OAAA,CAAAC,OAAA,GAAA7B,QAAA","ignoreList":[]}
|
package/createGraphQLSchema.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context } from "@webiny/api/types";
|
|
2
|
-
import { GraphQLSchemaPlugin } from "./plugins";
|
|
1
|
+
import type { Context } from "@webiny/api/types";
|
|
2
|
+
import type { GraphQLSchemaPlugin } from "./plugins";
|
|
3
3
|
export declare const getSchemaPlugins: (context: Context) => import("@webiny/plugins/PluginsContainer").WithName<GraphQLSchemaPlugin<Context>>[];
|
|
4
4
|
export declare const createGraphQLSchema: (context: Context) => import("graphql").GraphQLSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphqlTag","_interopRequireDefault","require","_schema","_merge","_builtInTypes","_ResolverDecoration","getSchemaPlugins","context","plugins","byType","filter","pl","isApplicable","exports","createGraphQLSchema","scalars","map","item","scalar","typeDefs","gql","name","join","resolvers","reduce","acc","s","JSON","JsonScalar","Long","LongScalar","RefInput","RefInputScalar","Number","NumberScalar","Any","AnyScalar","DateTime","DateTimeScalar","Date","DateScalar","Time","TimeScalar","resolverDecoration","ResolverDecoration","plugin","schema","push","resolverDecorators","addDecorators","makeExecutableSchema","decorateResolvers","mergeResolvers","inheritResolversFromInterfaces"],"sources":["createGraphQLSchema.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport { makeExecutableSchema } from \"@graphql-tools/schema\";\nimport { mergeResolvers } from \"@graphql-tools/merge\";\nimport { GraphQLScalarType } from \"graphql/type/definition\";\nimport { GraphQLScalarPlugin, Resolvers, TypeDefs } from \"./types\";\nimport { Context } from \"@webiny/api/types\";\nimport {\n RefInputScalar,\n NumberScalar,\n AnyScalar,\n DateScalar,\n DateTimeScalar,\n JsonScalar,\n TimeScalar,\n LongScalar\n} from \"./builtInTypes\";\nimport { ResolverDecoration } from \"./ResolverDecoration\";\nimport { GraphQLSchemaPlugin } from \"~/plugins\";\n\nexport const getSchemaPlugins = (context: Context) => {\n return context.plugins.byType<GraphQLSchemaPlugin>(\"graphql-schema\").filter(pl => {\n if (typeof pl.isApplicable === \"function\") {\n return pl.isApplicable(context);\n }\n return true;\n });\n};\n\nexport const createGraphQLSchema = (context: Context) => {\n const scalars = context.plugins\n .byType<GraphQLScalarPlugin>(\"graphql-scalar\")\n .map(item => item.scalar);\n\n // TODO: once the API packages are more closed, we'll have the opportunity\n // TODO: to maybe import the @ps directive from `api-prerendering-service` package.\n const typeDefs: TypeDefs[] = [\n gql`\n type Query\n type Mutation\n ${scalars.map(scalar => `scalar ${scalar.name}`).join(\" \")}\n scalar JSON\n scalar Long\n scalar RefInput\n scalar Number\n scalar Any\n scalar Date\n scalar DateTime\n scalar Time\n\n # This directive doesn't do anything on the GraphQL resolution level. It just serves\n # as a way to tell the Prerendering Service whether the GraphQL query needs to be\n # cached or not.\n directive @ps(cache: Boolean) on QUERY\n\n type Error {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type BooleanResponse {\n data: Boolean\n error: Error\n }\n `\n ];\n\n const resolvers: Resolvers<any>[] = [\n {\n ...scalars.reduce<Record<string, GraphQLScalarType>>((acc, s) => {\n acc[s.name] = s;\n return acc;\n }, {}),\n JSON: JsonScalar,\n Long: LongScalar,\n RefInput: RefInputScalar,\n Number: NumberScalar,\n Any: AnyScalar,\n DateTime: DateTimeScalar,\n Date: DateScalar,\n Time: TimeScalar\n }\n ];\n\n const resolverDecoration = new ResolverDecoration();\n\n const plugins = getSchemaPlugins(context);\n\n for (const plugin of plugins) {\n const schema = plugin.schema;\n if (schema.typeDefs) {\n typeDefs.push(schema.typeDefs);\n }\n if (schema.resolvers) {\n resolvers.push(schema.resolvers);\n }\n if (schema.resolverDecorators) {\n resolverDecoration.addDecorators(schema.resolverDecorators);\n }\n }\n\n return makeExecutableSchema({\n typeDefs,\n resolvers: resolverDecoration.decorateResolvers(mergeResolvers(resolvers)),\n inheritResolversFromInterfaces: true\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAIA,IAAAG,aAAA,GAAAH,OAAA;AAUA,IAAAI,mBAAA,GAAAJ,OAAA;AAGO,MAAMK,gBAAgB,G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I,EAAEC;EACV,CAAC,CACJ;EAED,MAAMC,kBAAkB,GAAG,IAAIC,sCAAkB,CAAC,CAAC;EAEnD,MAAMpC,OAAO,GAAGF,gBAAgB,CAACC,OAAO,CAAC;EAEzC,KAAK,MAAMsC,MAAM,IAAIrC,OAAO,EAAE;IAC1B,MAAMsC,MAAM,GAAGD,MAAM,CAACC,MAAM;IAC5B,IAAIA,MAAM,CAAC3B,QAAQ,EAAE;MACjBA,QAAQ,CAAC4B,IAAI,CAACD,MAAM,CAAC3B,QAAQ,CAAC;IAClC;IACA,IAAI2B,MAAM,CAACvB,SAAS,EAAE;MAClBA,SAAS,CAACwB,IAAI,CAACD,MAAM,CAACvB,SAAS,CAAC;IACpC;IACA,IAAIuB,MAAM,CAACE,kBAAkB,EAAE;MAC3BL,kBAAkB,CAACM,aAAa,CAACH,MAAM,CAACE,kBAAkB,CAAC;IAC/D;EACJ;EAEA,OAAO,IAAAE,4BAAoB,EAAC;IACxB/B,QAAQ;IACRI,SAAS,EAAEoB,kBAAkB,CAACQ,iBAAiB,CAAC,IAAAC,qBAAc,EAAC7B,SAAS,CAAC,CAAC;IAC1E8B,8BAA8B,EAAE;EACpC,CAAC,CAAC;AACN,CAAC;AAACxC,OAAA,CAAAC,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_graphqlTag","_interopRequireDefault","require","_schema","_merge","_builtInTypes","_ResolverDecoration","getSchemaPlugins","context","plugins","byType","filter","pl","isApplicable","exports","createGraphQLSchema","scalars","map","item","scalar","typeDefs","gql","name","join","resolvers","reduce","acc","s","JSON","JsonScalar","Long","LongScalar","RefInput","RefInputScalar","Number","NumberScalar","Any","AnyScalar","DateTime","DateTimeScalar","Date","DateScalar","Time","TimeScalar","resolverDecoration","ResolverDecoration","plugin","schema","push","resolverDecorators","addDecorators","makeExecutableSchema","decorateResolvers","mergeResolvers","inheritResolversFromInterfaces"],"sources":["createGraphQLSchema.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport { makeExecutableSchema } from \"@graphql-tools/schema\";\nimport { mergeResolvers } from \"@graphql-tools/merge\";\nimport type { GraphQLScalarType } from \"graphql/type/definition\";\nimport type { GraphQLScalarPlugin, Resolvers, TypeDefs } from \"./types\";\nimport type { Context } from \"@webiny/api/types\";\nimport {\n RefInputScalar,\n NumberScalar,\n AnyScalar,\n DateScalar,\n DateTimeScalar,\n JsonScalar,\n TimeScalar,\n LongScalar\n} from \"./builtInTypes\";\nimport { ResolverDecoration } from \"./ResolverDecoration\";\nimport type { GraphQLSchemaPlugin } from \"~/plugins\";\n\nexport const getSchemaPlugins = (context: Context) => {\n return context.plugins.byType<GraphQLSchemaPlugin>(\"graphql-schema\").filter(pl => {\n if (typeof pl.isApplicable === \"function\") {\n return pl.isApplicable(context);\n }\n return true;\n });\n};\n\nexport const createGraphQLSchema = (context: Context) => {\n const scalars = context.plugins\n .byType<GraphQLScalarPlugin>(\"graphql-scalar\")\n .map(item => item.scalar);\n\n // TODO: once the API packages are more closed, we'll have the opportunity\n // TODO: to maybe import the @ps directive from `api-prerendering-service` package.\n const typeDefs: TypeDefs[] = [\n gql`\n type Query\n type Mutation\n ${scalars.map(scalar => `scalar ${scalar.name}`).join(\" \")}\n scalar JSON\n scalar Long\n scalar RefInput\n scalar Number\n scalar Any\n scalar Date\n scalar DateTime\n scalar Time\n\n # This directive doesn't do anything on the GraphQL resolution level. It just serves\n # as a way to tell the Prerendering Service whether the GraphQL query needs to be\n # cached or not.\n directive @ps(cache: Boolean) on QUERY\n\n type Error {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type BooleanResponse {\n data: Boolean\n error: Error\n }\n `\n ];\n\n const resolvers: Resolvers<any>[] = [\n {\n ...scalars.reduce<Record<string, GraphQLScalarType>>((acc, s) => {\n acc[s.name] = s;\n return acc;\n }, {}),\n JSON: JsonScalar,\n Long: LongScalar,\n RefInput: RefInputScalar,\n Number: NumberScalar,\n Any: AnyScalar,\n DateTime: DateTimeScalar,\n Date: DateScalar,\n Time: TimeScalar\n }\n ];\n\n const resolverDecoration = new ResolverDecoration();\n\n const plugins = getSchemaPlugins(context);\n\n for (const plugin of plugins) {\n const schema = plugin.schema;\n if (schema.typeDefs) {\n typeDefs.push(schema.typeDefs);\n }\n if (schema.resolvers) {\n resolvers.push(schema.resolvers);\n }\n if (schema.resolverDecorators) {\n resolverDecoration.addDecorators(schema.resolverDecorators);\n }\n }\n\n return makeExecutableSchema({\n typeDefs,\n resolvers: resolverDecoration.decorateResolvers(mergeResolvers(resolvers)),\n inheritResolversFromInterfaces: true\n });\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAIA,IAAAG,aAAA,GAAAH,OAAA;AAUA,IAAAI,mBAAA,GAAAJ,OAAA;AAGO,MAAMK,gBAAgB,GAAIC,OAAgB,IAAK;EAClD,OAAOA,OAAO,CAACC,OAAO,CAACC,MAAM,CAAsB,gBAAgB,CAAC,CAACC,MAAM,CAACC,EAAE,IAAI;IAC9E,IAAI,OAAOA,EAAE,CAACC,YAAY,KAAK,UAAU,EAAE;MACvC,OAAOD,EAAE,CAACC,YAAY,CAACL,OAAO,CAAC;IACnC;IACA,OAAO,IAAI;EACf,CAAC,CAAC;AACN,CAAC;AAACM,OAAA,CAAAP,gBAAA,GAAAA,gBAAA;AAEK,MAAMQ,mBAAmB,GAAIP,OAAgB,IAAK;EACrD,MAAMQ,OAAO,GAAGR,OAAO,CAACC,OAAO,CAC1BC,MAAM,CAAsB,gBAAgB,CAAC,CAC7CO,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,MAAM,CAAC;;EAE7B;EACA;EACA,MAAMC,QAAoB,GAAG,CACzB,IAAAC,mBAAG;AACX;AACA;AACA,cAAcL,OAAO,CAACC,GAAG,CAACE,MAAM,IAAI,UAAUA,MAAM,CAACG,IAAI,EAAE,CAAC,CAACC,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AC,IAAAC,qBAAc,EAAC7B,SAAS,CAAC,CAAC;IAC1E8B,8BAA8B,EAAE;EACpC,CAAC,CAAC;AACN,CAAC;AAACxC,OAAA,CAAAC,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ResolverDecorator } from "./types";
|
|
1
|
+
import type { ResolverDecorator } from "./types";
|
|
2
2
|
export declare const createResolverDecorator: <TSource = any, TContext = any, TArgs = any>(decorator: ResolverDecorator<TSource, TContext, TArgs>) => ResolverDecorator<TSource, TContext, TArgs>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createResolverDecorator","decorator","exports"],"sources":["createResolverDecorator.ts"],"sourcesContent":["import { ResolverDecorator } from \"./types\";\n\nexport const createResolverDecorator = <TSource = any, TContext = any, TArgs = any>(\n decorator: ResolverDecorator<TSource, TContext, TArgs>\n) => {\n return decorator;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,uBAAuB,GAChCC,SAAsD,IACrD;EACD,OAAOA,SAAS;AACpB,CAAC;AAACC,OAAA,CAAAF,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["createResolverDecorator","decorator","exports"],"sources":["createResolverDecorator.ts"],"sourcesContent":["import type { ResolverDecorator } from \"./types\";\n\nexport const createResolverDecorator = <TSource = any, TContext = any, TArgs = any>(\n decorator: ResolverDecorator<TSource, TContext, TArgs>\n) => {\n return decorator;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,uBAAuB,GAChCC,SAAsD,IACrD;EACD,OAAOA,SAAS;AACpB,CAAC;AAACC,OAAA,CAAAF,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
package/debugPlugins.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GraphQLAfterQueryPlugin } from "./types";
|
|
2
|
-
import { Context } from "@webiny/api/types";
|
|
1
|
+
import type { GraphQLAfterQueryPlugin } from "./types";
|
|
2
|
+
import type { Context } from "@webiny/api/types";
|
|
3
3
|
import { ContextPlugin } from "@webiny/api";
|
|
4
4
|
interface Log {
|
|
5
5
|
method: string;
|
package/debugPlugins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_interceptConsole","require","_api","_default","ContextPlugin","context","debug","logs","interceptConsole","method","args","push","type","apply","result","console","length","exports","default"],"sources":["debugPlugins.ts"],"sourcesContent":["import { interceptConsole } from \"./interceptConsole\";\nimport { GraphQLAfterQueryPlugin } from \"./types\";\nimport { Context } from \"@webiny/api/types\";\nimport { ContextPlugin } from \"@webiny/api\";\n\ninterface Log {\n method: string;\n args: any;\n}\ninterface DebugContext extends Context {\n debug: {\n logs?: Log[];\n };\n}\n\nexport default () => [\n new ContextPlugin<DebugContext>(async context => {\n if (!context.debug) {\n context.debug = {};\n }\n\n if (!context.debug.logs) {\n context.debug.logs = [];\n }\n\n interceptConsole((method, args) => {\n (context.debug.logs as Log[]).push({ method, args });\n });\n }),\n {\n type: \"graphql-after-query\",\n apply({ result, context }) {\n result[\"extensions\"] = { console: [...(context.debug.logs || [])] };\n if (context.debug.logs) {\n context.debug.logs.length = 0;\n }\n }\n } as GraphQLAfterQueryPlugin<DebugContext>\n];\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAGA,IAAAC,IAAA,GAAAD,OAAA;AAA4C,IAAAE,QAAA,GAY7BA,CAAA,KAAM,CACjB,IAAIC,kBAAa,CAAe,MAAMC,OAAO,IAAI;EAC7C,IAAI,CAACA,OAAO,CAACC,KAAK,EAAE;IAChBD,OAAO,CAACC,KAAK,GAAG,CAAC,CAAC;EACtB;EAEA,IAAI,CAACD,OAAO,CAACC,KAAK,CAACC,IAAI,EAAE;IACrBF,OAAO,CAACC,KAAK,CAACC,IAAI,GAAG,EAAE;EAC3B;EAEA,IAAAC,kCAAgB,EAAC,CAACC,MAAM,EAAEC,IAAI,KAAK;IAC9BL,OAAO,CAACC,KAAK,CAACC,IAAI,CAAWI,IAAI,CAAC;MAAEF,MAAM;MAAEC;IAAK,CAAC,CAAC;EACxD,CAAC,CAAC;AACN,CAAC,CAAC,EACF;EACIE,IAAI,EAAE,qBAAqB;EAC3BC,KAAKA,CAAC;IAAEC,MAAM;IAAET;EAAQ,CAAC,EAAE;IACvBS,MAAM,CAAC,YAAY,CAAC,GAAG;MAAEC,OAAO,EAAE,CAAC,IAAIV,OAAO,CAACC,KAAK,CAACC,IAAI,IAAI,EAAE,CAAC;IAAE,CAAC;IACnE,IAAIF,OAAO,CAACC,KAAK,CAACC,IAAI,EAAE;MACpBF,OAAO,CAACC,KAAK,CAACC,IAAI,CAACS,MAAM,GAAG,CAAC;IACjC;EACJ;AACJ,CAAC,CACJ;AAAAC,OAAA,CAAAC,OAAA,GAAAf,QAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_interceptConsole","require","_api","_default","ContextPlugin","context","debug","logs","interceptConsole","method","args","push","type","apply","result","console","length","exports","default"],"sources":["debugPlugins.ts"],"sourcesContent":["import { interceptConsole } from \"./interceptConsole\";\nimport type { GraphQLAfterQueryPlugin } from \"./types\";\nimport type { Context } from \"@webiny/api/types\";\nimport { ContextPlugin } from \"@webiny/api\";\n\ninterface Log {\n method: string;\n args: any;\n}\ninterface DebugContext extends Context {\n debug: {\n logs?: Log[];\n };\n}\n\nexport default () => [\n new ContextPlugin<DebugContext>(async context => {\n if (!context.debug) {\n context.debug = {};\n }\n\n if (!context.debug.logs) {\n context.debug.logs = [];\n }\n\n interceptConsole((method, args) => {\n (context.debug.logs as Log[]).push({ method, args });\n });\n }),\n {\n type: \"graphql-after-query\",\n apply({ result, context }) {\n result[\"extensions\"] = { console: [...(context.debug.logs || [])] };\n if (context.debug.logs) {\n context.debug.logs.length = 0;\n }\n }\n } as GraphQLAfterQueryPlugin<DebugContext>\n];\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAGA,IAAAC,IAAA,GAAAD,OAAA;AAA4C,IAAAE,QAAA,GAY7BA,CAAA,KAAM,CACjB,IAAIC,kBAAa,CAAe,MAAMC,OAAO,IAAI;EAC7C,IAAI,CAACA,OAAO,CAACC,KAAK,EAAE;IAChBD,OAAO,CAACC,KAAK,GAAG,CAAC,CAAC;EACtB;EAEA,IAAI,CAACD,OAAO,CAACC,KAAK,CAACC,IAAI,EAAE;IACrBF,OAAO,CAACC,KAAK,CAACC,IAAI,GAAG,EAAE;EAC3B;EAEA,IAAAC,kCAAgB,EAAC,CAACC,MAAM,EAAEC,IAAI,KAAK;IAC9BL,OAAO,CAACC,KAAK,CAACC,IAAI,CAAWI,IAAI,CAAC;MAAEF,MAAM;MAAEC;IAAK,CAAC,CAAC;EACxD,CAAC,CAAC;AACN,CAAC,CAAC,EACF;EACIE,IAAI,EAAE,qBAAqB;EAC3BC,KAAKA,CAAC;IAAEC,MAAM;IAAET;EAAQ,CAAC,EAAE;IACvBS,MAAM,CAAC,YAAY,CAAC,GAAG;MAAEC,OAAO,EAAE,CAAC,IAAIV,OAAO,CAACC,KAAK,CAACC,IAAI,IAAI,EAAE,CAAC;IAAE,CAAC;IACnE,IAAIF,OAAO,CAACC,KAAK,CAACC,IAAI,EAAE;MACpBF,OAAO,CAACC,KAAK,CAACC,IAAI,CAACS,MAAM,GAAG,CAAC;IACjC;EACJ;AACJ,CAAC,CACJ;AAAAC,OAAA,CAAAC,OAAA,GAAAf,QAAA","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins/types";
|
|
2
|
-
import { HandlerGraphQLOptions } from "./types";
|
|
1
|
+
import type { Plugin } from "@webiny/plugins/types";
|
|
2
|
+
import type { HandlerGraphQLOptions } from "./types";
|
|
3
3
|
export * from "./errors";
|
|
4
4
|
export * from "./responses";
|
|
5
5
|
export * from "./utils";
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_createGraphQLHandler","_interopRequireDefault","require","_errors","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_responses","_utils","_plugins","_processRequestBody","_createResolverDecorator","_ResolverDecoration","_default","options","createGraphQLHandler","default"],"sources":["index.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/types\";\nimport { HandlerGraphQLOptions } from \"./types\";\nimport createGraphQLHandler from \"./createGraphQLHandler\";\n\nexport * from \"./errors\";\nexport * from \"./responses\";\nexport * from \"./utils\";\nexport * from \"./plugins\";\nexport * from \"./processRequestBody\";\nexport * from \"./createResolverDecorator\";\nexport * from \"./ResolverDecoration\";\n\nexport default (options: HandlerGraphQLOptions = {}): Plugin[] => {\n return createGraphQLHandler(options);\n};\n"],"mappings":";;;;;;;;AAEA,IAAAA,qBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,UAAA,GAAAd,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAW,UAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA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A,GAEtBA,CAACC,OAA8B,GAAG,CAAC,CAAC,KAAe;EAC9D,OAAO,IAAAC,6BAAoB,EAACD,OAAO,CAAC;AACxC,CAAC;AAAAX,OAAA,CAAAa,OAAA,GAAAH,QAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_createGraphQLHandler","_interopRequireDefault","require","_errors","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_responses","_utils","_plugins","_processRequestBody","_createResolverDecorator","_ResolverDecoration","_default","options","createGraphQLHandler","default"],"sources":["index.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types\";\nimport type { HandlerGraphQLOptions } from \"./types\";\nimport createGraphQLHandler from \"./createGraphQLHandler\";\n\nexport * from \"./errors\";\nexport * from \"./responses\";\nexport * from \"./utils\";\nexport * from \"./plugins\";\nexport * from \"./processRequestBody\";\nexport * from \"./createResolverDecorator\";\nexport * from \"./ResolverDecoration\";\n\nexport default (options: HandlerGraphQLOptions = {}): Plugin[] => {\n return createGraphQLHandler(options);\n};\n"],"mappings":";;;;;;;;AAEA,IAAAA,qBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,UAAA,GAAAd,OAAA;AAAAE,MAAA,CAAAC,IAAA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AL,GAAA,MAAAc,mBAAA,CAAAd,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAM,mBAAA,CAAAd,GAAA;IAAA;EAAA;AAAA;AAAqC,IAAAe,QAAA,GAEtBA,CAACC,OAA8B,GAAG,CAAC,CAAC,KAAe;EAC9D,OAAO,IAAAC,6BAAoB,EAACD,OAAO,CAAC;AACxC,CAAC;AAAAX,OAAA,CAAAa,OAAA,GAAAH,QAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/handler-graphql",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"@graphql-tools/resolvers-composition": "7.0.2",
|
|
19
19
|
"@graphql-tools/schema": "10.0.7",
|
|
20
20
|
"@graphql-tools/utils": "10.5.5",
|
|
21
|
-
"@webiny/api": "6.0.0-alpha.
|
|
22
|
-
"@webiny/error": "6.0.0-alpha.
|
|
23
|
-
"@webiny/handler": "6.0.0-alpha.
|
|
24
|
-
"@webiny/plugins": "6.0.0-alpha.
|
|
21
|
+
"@webiny/api": "6.0.0-alpha.1",
|
|
22
|
+
"@webiny/error": "6.0.0-alpha.1",
|
|
23
|
+
"@webiny/handler": "6.0.0-alpha.1",
|
|
24
|
+
"@webiny/plugins": "6.0.0-alpha.1",
|
|
25
25
|
"boolean": "3.2.0",
|
|
26
26
|
"graphql": "15.9.0",
|
|
27
27
|
"graphql-scalars": "1.12.0",
|
|
28
28
|
"graphql-tag": "2.12.6"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@webiny/handler-aws": "6.0.0-alpha.
|
|
32
|
-
"@webiny/project-utils": "6.0.0-alpha.
|
|
31
|
+
"@webiny/handler-aws": "6.0.0-alpha.1",
|
|
32
|
+
"@webiny/project-utils": "6.0.0-alpha.1",
|
|
33
33
|
"jest": "29.7.0",
|
|
34
34
|
"jest-mock-console": "2.0.0",
|
|
35
35
|
"rimraf": "6.0.1",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"build": "node ../cli/bin.js run build",
|
|
44
44
|
"watch": "node ../cli/bin.js run watch"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "9bd236cf5e689f209a11bec089207dcc2d41a53c"
|
|
47
47
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Context } from "@webiny/api/types";
|
|
1
|
+
import type { Context } from "@webiny/api/types";
|
|
2
2
|
import { Plugin } from "@webiny/plugins";
|
|
3
|
-
import { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from "../types";
|
|
3
|
+
import type { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from "../types";
|
|
4
4
|
export interface IGraphQLSchemaPlugin<TContext = Context> extends Plugin {
|
|
5
5
|
schema: GraphQLSchemaDefinition<TContext>;
|
|
6
6
|
isApplicable: (context: TContext) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_plugins","require","GraphQLSchemaPlugin","Plugin","type","constructor","config","schema","typeDefs","resolvers","resolverDecorators","isApplicable","context","exports","createGraphQLSchemaPlugin"],"sources":["GraphQLSchemaPlugin.ts"],"sourcesContent":["import { Context } from \"@webiny/api/types\";\nimport { Plugin } from \"@webiny/plugins\";\nimport { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from \"~/types\";\n\nexport interface IGraphQLSchemaPlugin<TContext = Context> extends Plugin {\n schema: GraphQLSchemaDefinition<TContext>;\n isApplicable: (context: TContext) => boolean;\n}\n\nexport interface GraphQLSchemaPluginConfig<TContext> {\n typeDefs?: TypeDefs;\n resolvers?: Resolvers<TContext>;\n resolverDecorators?: ResolverDecorators;\n isApplicable?: (context: TContext) => boolean;\n}\n\nexport class GraphQLSchemaPlugin<TContext = Context>\n extends Plugin\n implements IGraphQLSchemaPlugin<TContext>\n{\n public static override readonly type: string = \"graphql-schema\";\n protected config: GraphQLSchemaPluginConfig<TContext>;\n\n constructor(config: GraphQLSchemaPluginConfig<TContext>) {\n super();\n this.config = config;\n }\n\n get schema(): GraphQLSchemaDefinition<TContext> {\n return {\n typeDefs: this.config.typeDefs || \"\",\n resolvers: this.config.resolvers,\n resolverDecorators: this.config.resolverDecorators\n };\n }\n\n isApplicable(context: TContext): boolean {\n if (this.config.isApplicable) {\n return this.config.isApplicable(context);\n }\n return true;\n }\n}\n\nexport const createGraphQLSchemaPlugin = <T = Context>(config: GraphQLSchemaPluginConfig<T>) => {\n return new GraphQLSchemaPlugin<T>(config);\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAeO,MAAMC,mBAAmB,SACpBC,eAAM,CAElB;EACI,OAAgCC,IAAI,GAAW,gBAAgB;EAG/DC,WAAWA,CAACC,MAA2C,EAAE;IACrD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,IAAIC,MAAMA,CAAA,EAAsC;IAC5C,OAAO;MACHC,QAAQ,EAAE,IAAI,CAACF,MAAM,CAACE,QAAQ,IAAI,EAAE;MACpCC,SAAS,EAAE,IAAI,CAACH,MAAM,CAACG,SAAS;MAChCC,kBAAkB,EAAE,IAAI,CAACJ,MAAM,CAACI;IACpC,CAAC;EACL;EAEAC,YAAYA,CAACC,OAAiB,EAAW;IACrC,IAAI,IAAI,CAACN,MAAM,CAACK,YAAY,EAAE;MAC1B,OAAO,IAAI,CAACL,MAAM,CAACK,YAAY,CAACC,OAAO,CAAC;IAC5C;IACA,OAAO,IAAI;EACf;AACJ;AAACC,OAAA,CAAAX,mBAAA,GAAAA,mBAAA;AAEM,MAAMY,yBAAyB,GAAiBR,MAAoC,IAAK;EAC5F,OAAO,IAAIJ,mBAAmB,CAAII,MAAM,CAAC;AAC7C,CAAC;AAACO,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_plugins","require","GraphQLSchemaPlugin","Plugin","type","constructor","config","schema","typeDefs","resolvers","resolverDecorators","isApplicable","context","exports","createGraphQLSchemaPlugin"],"sources":["GraphQLSchemaPlugin.ts"],"sourcesContent":["import type { Context } from \"@webiny/api/types\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from \"~/types\";\n\nexport interface IGraphQLSchemaPlugin<TContext = Context> extends Plugin {\n schema: GraphQLSchemaDefinition<TContext>;\n isApplicable: (context: TContext) => boolean;\n}\n\nexport interface GraphQLSchemaPluginConfig<TContext> {\n typeDefs?: TypeDefs;\n resolvers?: Resolvers<TContext>;\n resolverDecorators?: ResolverDecorators;\n isApplicable?: (context: TContext) => boolean;\n}\n\nexport class GraphQLSchemaPlugin<TContext = Context>\n extends Plugin\n implements IGraphQLSchemaPlugin<TContext>\n{\n public static override readonly type: string = \"graphql-schema\";\n protected config: GraphQLSchemaPluginConfig<TContext>;\n\n constructor(config: GraphQLSchemaPluginConfig<TContext>) {\n super();\n this.config = config;\n }\n\n get schema(): GraphQLSchemaDefinition<TContext> {\n return {\n typeDefs: this.config.typeDefs || \"\",\n resolvers: this.config.resolvers,\n resolverDecorators: this.config.resolverDecorators\n };\n }\n\n isApplicable(context: TContext): boolean {\n if (this.config.isApplicable) {\n return this.config.isApplicable(context);\n }\n return true;\n }\n}\n\nexport const createGraphQLSchemaPlugin = <T = Context>(config: GraphQLSchemaPluginConfig<T>) => {\n return new GraphQLSchemaPlugin<T>(config);\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAeO,MAAMC,mBAAmB,SACpBC,eAAM,CAElB;EACI,OAAgCC,IAAI,GAAW,gBAAgB;EAG/DC,WAAWA,CAACC,MAA2C,EAAE;IACrD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,IAAIC,MAAMA,CAAA,EAAsC;IAC5C,OAAO;MACHC,QAAQ,EAAE,IAAI,CAACF,MAAM,CAACE,QAAQ,IAAI,EAAE;MACpCC,SAAS,EAAE,IAAI,CAACH,MAAM,CAACG,SAAS;MAChCC,kBAAkB,EAAE,IAAI,CAACJ,MAAM,CAACI;IACpC,CAAC;EACL;EAEAC,YAAYA,CAACC,OAAiB,EAAW;IACrC,IAAI,IAAI,CAACN,MAAM,CAACK,YAAY,EAAE;MAC1B,OAAO,IAAI,CAACL,MAAM,CAACK,YAAY,CAACC,OAAO,CAAC;IAC5C;IACA,OAAO,IAAI;EACf;AACJ;AAACC,OAAA,CAAAX,mBAAA,GAAAA,mBAAA;AAEM,MAAMY,yBAAyB,GAAiBR,MAAoC,IAAK;EAC5F,OAAO,IAAIJ,mBAAmB,CAAII,MAAM,CAAC;AAC7C,CAAC;AAACO,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
package/processRequestBody.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ExecutionResult, GraphQLSchema } from "graphql";
|
|
2
|
-
import { GraphQLRequestBody } from "./types";
|
|
2
|
+
import type { GraphQLRequestBody } from "./types";
|
|
3
3
|
import type { Context } from "@webiny/api/types";
|
|
4
4
|
export declare const processRequestBody: <TData = Record<string, any>, TExtensions = Record<string, any>>(requestBody: GraphQLRequestBody | GraphQLRequestBody[], schema: GraphQLSchema, context: Context) => Promise<ExecutionResult<TData, TExtensions> | ExecutionResult<TData, TExtensions>[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphql","require","executeGraphQl","body","schema","context","query","variables","operationName","plugins","byType","forEach","pl","apply","result","graphql","source","rootValue","contextValue","variableValues","processRequestBody","requestBody","Array","isArray","results","push","exports"],"sources":["processRequestBody.ts"],"sourcesContent":["import type { ExecutionResult, GraphQLSchema } from \"graphql\";\nimport { graphql } from \"graphql\";\nimport {
|
|
1
|
+
{"version":3,"names":["_graphql","require","executeGraphQl","body","schema","context","query","variables","operationName","plugins","byType","forEach","pl","apply","result","graphql","source","rootValue","contextValue","variableValues","processRequestBody","requestBody","Array","isArray","results","push","exports"],"sources":["processRequestBody.ts"],"sourcesContent":["import type { ExecutionResult, GraphQLSchema } from \"graphql\";\nimport { graphql } from \"graphql\";\nimport type {\n GraphQLAfterQueryPlugin,\n GraphQLBeforeQueryPlugin,\n GraphQLRequestBody\n} from \"~/types\";\nimport type { Context } from \"@webiny/api/types\";\n\nconst executeGraphQl = async <TData = Record<string, any>, TExtensions = Record<string, any>>(\n body: GraphQLRequestBody,\n schema: GraphQLSchema,\n context: Context\n): Promise<ExecutionResult<TData, TExtensions>> => {\n const { query, variables, operationName } = body;\n\n context.plugins\n .byType<GraphQLBeforeQueryPlugin>(\"graphql-before-query\")\n .forEach(pl => pl.apply({ body, schema, context }));\n\n const result = await graphql({\n schema,\n source: query,\n rootValue: {},\n contextValue: context,\n variableValues: variables,\n operationName\n });\n\n context.plugins.byType<GraphQLAfterQueryPlugin>(\"graphql-after-query\").forEach(pl => {\n pl.apply({ result, body, schema, context });\n });\n\n return result as ExecutionResult<TData, TExtensions>;\n};\n\nexport const processRequestBody = async <\n TData = Record<string, any>,\n TExtensions = Record<string, any>\n>(\n requestBody: GraphQLRequestBody | GraphQLRequestBody[],\n schema: GraphQLSchema,\n context: Context\n): Promise<ExecutionResult<TData, TExtensions>[] | ExecutionResult<TData, TExtensions>> => {\n if (Array.isArray(requestBody)) {\n const results: ExecutionResult<TData, TExtensions>[] = [];\n for (const body of requestBody) {\n const result = await executeGraphQl<TData, TExtensions>(body, schema, context);\n results.push(result);\n }\n return results;\n }\n return await executeGraphQl<TData, TExtensions>(requestBody, schema, context);\n};\n"],"mappings":";;;;;;AACA,IAAAA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AAEC,OAAO,CAAC;AACjF,CAAC;AAACqB,OAAA,CAAAN,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
package/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { GraphQLScalarType, GraphQLFieldResolver as BaseGraphQLFieldResolver, GraphQLSchema } from "graphql";
|
|
2
|
-
import { Plugin } from "@webiny/plugins/types";
|
|
3
|
-
import { Context, GenericRecord } from "@webiny/api/types";
|
|
4
|
-
import { RouteMethodPath } from "@webiny/handler/types";
|
|
5
|
-
import { ResolversComposition } from "@graphql-tools/resolvers-composition";
|
|
6
|
-
import { IResolvers, TypeSource } from "@graphql-tools/utils";
|
|
1
|
+
import type { GraphQLScalarType, GraphQLFieldResolver as BaseGraphQLFieldResolver, GraphQLSchema } from "graphql";
|
|
2
|
+
import type { Plugin } from "@webiny/plugins/types";
|
|
3
|
+
import type { Context, GenericRecord } from "@webiny/api/types";
|
|
4
|
+
import type { RouteMethodPath } from "@webiny/handler/types";
|
|
5
|
+
import type { ResolversComposition } from "@graphql-tools/resolvers-composition";
|
|
6
|
+
import type { IResolvers, TypeSource } from "@graphql-tools/utils";
|
|
7
7
|
export interface GraphQLScalarPlugin extends Plugin {
|
|
8
8
|
type: "graphql-scalar";
|
|
9
9
|
scalar: GraphQLScalarType;
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import {\n GraphQLScalarType,\n GraphQLFieldResolver as BaseGraphQLFieldResolver,\n GraphQLSchema\n} from \"graphql\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { Context, GenericRecord } from \"@webiny/api/types\";\nimport { RouteMethodPath } from \"@webiny/handler/types\";\nimport { ResolversComposition } from \"@graphql-tools/resolvers-composition\";\nimport { IResolvers, TypeSource } from \"@graphql-tools/utils\";\n\nexport interface GraphQLScalarPlugin extends Plugin {\n type: \"graphql-scalar\";\n scalar: GraphQLScalarType;\n}\n\nexport interface HandlerGraphQLOptions {\n path?: RouteMethodPath;\n debug?: boolean | string;\n}\n\nexport type GraphQLFieldResolver<\n TSource = any,\n TArgs = any,\n TContext = Context\n> = BaseGraphQLFieldResolver<TSource, TContext, TArgs>;\n\n/**\n * @deprecated Use `TypeDefs` instead.\n */\nexport type Types = TypeDefs;\nexport type TypeDefs = TypeSource;\n\nexport interface GraphQLSchemaPluginTypeArgs {\n context?: any;\n args?: any;\n source?: any;\n}\n\nexport type Resolvers<TContext> = IResolvers<any, TContext>;\n\nexport type ResolverDecorator<TSource = any, TContext = any, TArgs = any> = ResolversComposition<\n GraphQLFieldResolver<TSource, TContext, TArgs>\n>;\n\nexport type ResolverDecorators = GenericRecord<string, ResolverDecorator[]>;\n\nexport interface GraphQLSchemaDefinition<TContext> {\n typeDefs: TypeDefs;\n resolvers?: Resolvers<TContext>;\n resolverDecorators?: ResolverDecorators;\n}\n\nexport interface GraphQLSchemaPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-schema\";\n schema: GraphQLSchemaDefinition<TContext>;\n}\n\nexport interface GraphQLRequestBody {\n query: string;\n variables: Record<string, any>;\n operationName: string;\n}\n\nexport interface GraphQLBeforeQueryPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-before-query\";\n apply(params: { body: GraphQLRequestBody; schema: GraphQLSchema; context: TContext }): void;\n}\n\nexport interface GraphQLAfterQueryPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-after-query\";\n apply(params: {\n result: any;\n body: GraphQLRequestBody;\n schema: GraphQLSchema;\n context: TContext;\n }): void;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n GraphQLScalarType,\n GraphQLFieldResolver as BaseGraphQLFieldResolver,\n GraphQLSchema\n} from \"graphql\";\nimport type { Plugin } from \"@webiny/plugins/types\";\nimport type { Context, GenericRecord } from \"@webiny/api/types\";\nimport type { RouteMethodPath } from \"@webiny/handler/types\";\nimport type { ResolversComposition } from \"@graphql-tools/resolvers-composition\";\nimport type { IResolvers, TypeSource } from \"@graphql-tools/utils\";\n\nexport interface GraphQLScalarPlugin extends Plugin {\n type: \"graphql-scalar\";\n scalar: GraphQLScalarType;\n}\n\nexport interface HandlerGraphQLOptions {\n path?: RouteMethodPath;\n debug?: boolean | string;\n}\n\nexport type GraphQLFieldResolver<\n TSource = any,\n TArgs = any,\n TContext = Context\n> = BaseGraphQLFieldResolver<TSource, TContext, TArgs>;\n\n/**\n * @deprecated Use `TypeDefs` instead.\n */\nexport type Types = TypeDefs;\nexport type TypeDefs = TypeSource;\n\nexport interface GraphQLSchemaPluginTypeArgs {\n context?: any;\n args?: any;\n source?: any;\n}\n\nexport type Resolvers<TContext> = IResolvers<any, TContext>;\n\nexport type ResolverDecorator<TSource = any, TContext = any, TArgs = any> = ResolversComposition<\n GraphQLFieldResolver<TSource, TContext, TArgs>\n>;\n\nexport type ResolverDecorators = GenericRecord<string, ResolverDecorator[]>;\n\nexport interface GraphQLSchemaDefinition<TContext> {\n typeDefs: TypeDefs;\n resolvers?: Resolvers<TContext>;\n resolverDecorators?: ResolverDecorators;\n}\n\nexport interface GraphQLSchemaPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-schema\";\n schema: GraphQLSchemaDefinition<TContext>;\n}\n\nexport interface GraphQLRequestBody {\n query: string;\n variables: Record<string, any>;\n operationName: string;\n}\n\nexport interface GraphQLBeforeQueryPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-before-query\";\n apply(params: { body: GraphQLRequestBody; schema: GraphQLSchema; context: TContext }): void;\n}\n\nexport interface GraphQLAfterQueryPlugin<TContext extends Context = Context> extends Plugin {\n type: \"graphql-after-query\";\n apply(params: {\n result: any;\n body: GraphQLRequestBody;\n schema: GraphQLSchema;\n context: TContext;\n }): void;\n}\n"],"mappings":"","ignoreList":[]}
|
package/utils/resolve.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorResponse, ListErrorResponse, ListResponse, Response } from "../responses";
|
|
2
|
-
import { GenericRecord } from "@webiny/api/types";
|
|
2
|
+
import type { GenericRecord } from "@webiny/api/types";
|
|
3
3
|
export interface Meta {
|
|
4
4
|
totalCount: number;
|
|
5
5
|
hasMoreItems: boolean;
|
package/utils/resolve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_responses","require","emptyResolver","exports","resolve","fn","Response","ex","ErrorResponse","resolveList","result","ListResponse","items","meta","ListErrorResponse"],"sources":["resolve.ts"],"sourcesContent":["import { ErrorResponse, ListErrorResponse, ListResponse, Response } from \"~/responses\";\nimport { GenericRecord } from \"@webiny/api/types\";\n\nexport interface Meta {\n totalCount: number;\n hasMoreItems: boolean;\n cursor: string | null;\n}\n\nexport const emptyResolver = () => ({});\n\ninterface ResolveCallable<T = GenericRecord> {\n (): Promise<T>;\n}\n\nexport const resolve = async <T = GenericRecord>(fn: ResolveCallable<T>) => {\n try {\n return new Response(await fn());\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\ninterface ResolveListCallable<T> {\n (): Promise<IListResult<T>>;\n}\n\ninterface IListResult<T = GenericRecord> {\n items: T[];\n meta: Meta;\n}\n\nexport const resolveList = async <T = GenericRecord>(fn: ResolveListCallable<T>) => {\n try {\n const result = (await fn()) as IListResult<T>;\n return new ListResponse(result.items, result.meta);\n } catch (ex) {\n return new ListErrorResponse(ex);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AASO,MAAMC,aAAa,GAAGA,CAAA,MAAO,CAAC,CAAC,CAAC;AAACC,OAAA,CAAAD,aAAA,GAAAA,aAAA;AAMjC,MAAME,OAAO,GAAG,MAA0BC,EAAsB,IAAK;EACxE,IAAI;IACA,OAAO,IAAIC,mBAAQ,CAAC,MAAMD,EAAE,CAAC,CAAC,CAAC;EACnC,CAAC,CAAC,OAAOE,EAAE,EAAE;IACT,OAAO,IAAIC,wBAAa,CAACD,EAAE,CAAC;EAChC;AACJ,CAAC;AAACJ,OAAA,CAAAC,OAAA,GAAAA,OAAA;AAWK,MAAMK,WAAW,GAAG,MAA0BJ,EAA0B,IAAK;EAChF,IAAI;IACA,MAAMK,MAAM,GAAI,MAAML,EAAE,CAAC,CAAoB;IAC7C,OAAO,IAAIM,uBAAY,CAACD,MAAM,CAACE,KAAK,EAAEF,MAAM,CAACG,IAAI,CAAC;EACtD,CAAC,CAAC,OAAON,EAAE,EAAE;IACT,OAAO,IAAIO,4BAAiB,CAACP,EAAE,CAAC;EACpC;AACJ,CAAC;AAACJ,OAAA,CAAAM,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_responses","require","emptyResolver","exports","resolve","fn","Response","ex","ErrorResponse","resolveList","result","ListResponse","items","meta","ListErrorResponse"],"sources":["resolve.ts"],"sourcesContent":["import { ErrorResponse, ListErrorResponse, ListResponse, Response } from \"~/responses\";\nimport type { GenericRecord } from \"@webiny/api/types\";\n\nexport interface Meta {\n totalCount: number;\n hasMoreItems: boolean;\n cursor: string | null;\n}\n\nexport const emptyResolver = () => ({});\n\ninterface ResolveCallable<T = GenericRecord> {\n (): Promise<T>;\n}\n\nexport const resolve = async <T = GenericRecord>(fn: ResolveCallable<T>) => {\n try {\n return new Response(await fn());\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\ninterface ResolveListCallable<T> {\n (): Promise<IListResult<T>>;\n}\n\ninterface IListResult<T = GenericRecord> {\n items: T[];\n meta: Meta;\n}\n\nexport const resolveList = async <T = GenericRecord>(fn: ResolveListCallable<T>) => {\n try {\n const result = (await fn()) as IListResult<T>;\n return new ListResponse(result.items, result.meta);\n } catch (ex) {\n return new ListErrorResponse(ex);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AASO,MAAMC,aAAa,GAAGA,CAAA,MAAO,CAAC,CAAC,CAAC;AAACC,OAAA,CAAAD,aAAA,GAAAA,aAAA;AAMjC,MAAME,OAAO,GAAG,MAA0BC,EAAsB,IAAK;EACxE,IAAI;IACA,OAAO,IAAIC,mBAAQ,CAAC,MAAMD,EAAE,CAAC,CAAC,CAAC;EACnC,CAAC,CAAC,OAAOE,EAAE,EAAE;IACT,OAAO,IAAIC,wBAAa,CAACD,EAAE,CAAC;EAChC;AACJ,CAAC;AAACJ,OAAA,CAAAC,OAAA,GAAAA,OAAA;AAWK,MAAMK,WAAW,GAAG,MAA0BJ,EAA0B,IAAK;EAChF,IAAI;IACA,MAAMK,MAAM,GAAI,MAAML,EAAE,CAAC,CAAoB;IAC7C,OAAO,IAAIM,uBAAY,CAACD,MAAM,CAACE,KAAK,EAAEF,MAAM,CAACG,IAAI,CAAC;EACtD,CAAC,CAAC,OAAON,EAAE,EAAE;IACT,OAAO,IAAIO,4BAAiB,CAACP,EAAE,CAAC;EACpC;AACJ,CAAC;AAACJ,OAAA,CAAAM,WAAA,GAAAA,WAAA","ignoreList":[]}
|