@webiny/handler-graphql 5.41.4 → 5.42.0-beta.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/builtInTypes/AnyScalar.js.map +1 -1
- package/builtInTypes/LongScalar.js.map +1 -1
- package/builtInTypes/NumberScalar.js.map +1 -1
- package/builtInTypes/TimeScalar.js.map +1 -1
- package/createGraphQLHandler.js.map +1 -1
- package/createGraphQLSchema.d.ts +1 -1
- package/createGraphQLSchema.js +6 -1
- package/createGraphQLSchema.js.map +1 -1
- package/package.json +12 -16
- package/processRequestBody.d.ts +2 -2
- package/processRequestBody.js +8 -1
- package/processRequestBody.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphql","require","returnValue","value","AnyScalar","exports","GraphQLScalarType","name","description","serialize","parseValue"],"sources":["AnyScalar.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\n\nconst returnValue = (value: any): any => {\n return value;\n};\n\nexport const AnyScalar = new GraphQLScalarType({\n name: \"Any\",\n description: `A scalar type that represents an ambiguous value.`,\n serialize: returnValue,\n parseValue: returnValue\n});\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,MAAMC,WAAW,GAAIC,KAAU,IAAU;EACrC,OAAOA,KAAK;AAChB,CAAC;AAEM,MAAMC,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,IAAIE,0BAAiB,CAAC;EAC3CC,IAAI,EAAE,KAAK;EACXC,WAAW,
|
|
1
|
+
{"version":3,"names":["_graphql","require","returnValue","value","AnyScalar","exports","GraphQLScalarType","name","description","serialize","parseValue"],"sources":["AnyScalar.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\n\nconst returnValue = (value: any): any => {\n return value;\n};\n\nexport const AnyScalar = new GraphQLScalarType({\n name: \"Any\",\n description: `A scalar type that represents an ambiguous value.`,\n serialize: returnValue,\n parseValue: returnValue\n});\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,MAAMC,WAAW,GAAIC,KAAU,IAAU;EACrC,OAAOA,KAAK;AAChB,CAAC;AAEM,MAAMC,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,IAAIE,0BAAiB,CAAC;EAC3CC,IAAI,EAAE,KAAK;EACXC,WAAW,EAAE,mDAAmD;EAChEC,SAAS,EAAEP,WAAW;EACtBQ,UAAU,EAAER;AAChB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphql","require","_language","_error","_interopRequireDefault","parseValue","value","String","includes","WebinyError","undefined","isNaN","parseInt","LongScalar","exports","GraphQLScalarType","name","description","serialize","ex","console","log","message","code","data","parseLiteral","ast","kind","Kind","INT","Error"],"sources":["LongScalar.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\nimport { Kind } from \"graphql/language\";\nimport WebinyError from \"@webiny/error\";\n\nconst parseValue = (value: any) => {\n if (String(value).includes(\".\")) {\n throw new WebinyError(\"Value sent must be an integer.\", \"INVALID_VALUE\", {\n value\n });\n }\n if (typeof value === \"number\") {\n return value;\n }\n\n if (value === null || value === undefined) {\n return null;\n }\n\n if (isNaN(value) === true) {\n throw new WebinyError(\"Value sent must be an integer.\", \"INVALID_VALUE\", {\n value\n });\n }\n\n return parseInt(value);\n};\n\nexport const LongScalar = new GraphQLScalarType({\n name: \"Long\",\n description: \"A custom input type to be used for large integers (Long).\",\n serialize: (value: any) => {\n try {\n return parseValue(value);\n } catch (ex) {\n console.log({\n message: \"Value sent must be an integer.\",\n code: \"INVALID_VALUE\",\n data: {\n value\n }\n });\n return null;\n }\n },\n parseValue,\n parseLiteral: ast => {\n if (ast.kind === Kind.INT) {\n return parseInt(ast.value);\n }\n\n throw new Error(`Expected type Long, found {${ast.kind}}`);\n }\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD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3,"names":["_graphql","require","_language","_error","_interopRequireDefault","parseValue","value","String","includes","WebinyError","undefined","isNaN","parseInt","LongScalar","exports","GraphQLScalarType","name","description","serialize","ex","console","log","message","code","data","parseLiteral","ast","kind","Kind","INT","Error"],"sources":["LongScalar.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\nimport { Kind } from \"graphql/language\";\nimport WebinyError from \"@webiny/error\";\n\nconst parseValue = (value: any) => {\n if (String(value).includes(\".\")) {\n throw new WebinyError(\"Value sent must be an integer.\", \"INVALID_VALUE\", {\n value\n });\n }\n if (typeof value === \"number\") {\n return value;\n }\n\n if (value === null || value === undefined) {\n return null;\n }\n\n if (isNaN(value) === true) {\n throw new WebinyError(\"Value sent must be an integer.\", \"INVALID_VALUE\", {\n value\n });\n }\n\n return parseInt(value);\n};\n\nexport const LongScalar = new GraphQLScalarType({\n name: \"Long\",\n description: \"A custom input type to be used for large integers (Long).\",\n serialize: (value: any) => {\n try {\n return parseValue(value);\n } catch (ex) {\n console.log({\n message: \"Value sent must be an integer.\",\n code: \"INVALID_VALUE\",\n data: {\n value\n }\n });\n return null;\n }\n },\n parseValue,\n parseLiteral: ast => {\n if (ast.kind === Kind.INT) {\n return parseInt(ast.value);\n }\n\n throw new Error(`Expected type Long, found {${ast.kind}}`);\n }\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,MAAMI,UAAU,GAAIC,KAAU,IAAK;EAC/B,IAAIC,MAAM,CAACD,KAAK,CAAC,CAACE,QAAQ,CAAC,GAAG,CAAC,EAAE;IAC7B,MAAM,IAAIC,cAAW,CAAC,gCAAgC,EAAE,eAAe,EAAE;MACrEH;IACJ,CAAC,CAAC;EACN;EACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKI,SAAS,EAAE;IACvC,OAAO,IAAI;EACf;EAEA,IAAIC,KAAK,CAACL,KAAK,CAAC,KAAK,IAAI,EAAE;IACvB,MAAM,IAAIG,cAAW,CAAC,gCAAgC,EAAE,eAAe,EAAE;MACrEH;IACJ,CAAC,CAAC;EACN;EAEA,OAAOM,QAAQ,CAACN,KAAK,CAAC;AAC1B,CAAC;AAEM,MAAMO,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,IAAIE,0BAAiB,CAAC;EAC5CC,IAAI,EAAE,MAAM;EACZC,WAAW,EAAE,2DAA2D;EACxEC,SAAS,EAAGZ,KAAU,IAAK;IACvB,IAAI;MACA,OAAOD,UAAU,CAACC,KAAK,CAAC;IAC5B,CAAC,CAAC,OAAOa,EAAE,EAAE;MACTC,OAAO,CAACC,GAAG,CAAC;QACRC,OAAO,EAAE,gCAAgC;QACzCC,IAAI,EAAE,eAAe;QACrBC,IAAI,EAAE;UACFlB;QACJ;MACJ,CAAC,CAAC;MACF,OAAO,IAAI;IACf;EACJ,CAAC;EACDD,UAAU;EACVoB,YAAY,EAAEC,GAAG,IAAI;IACjB,IAAIA,GAAG,CAACC,IAAI,KAAKC,cAAI,CAACC,GAAG,EAAE;MACvB,OAAOjB,QAAQ,CAACc,GAAG,CAACpB,KAAK,CAAC;IAC9B;IAEA,MAAM,IAAIwB,KAAK,CAAC,8BAA8BJ,GAAG,CAACC,IAAI,GAAG,CAAC;EAC9D;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphql","require","_language","_error","_interopRequireDefault","parseValue","value","String","match","WebinyError","undefined","isNaN","parseFloat","NumberScalar","exports","GraphQLScalarType","name","description","serialize","ex","console","log","message","code","data","parseLiteral","ast","kind","Kind","INT","Number","FLOAT","Error"],"sources":["NumberScalar.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\nimport { Kind } from \"graphql/language\";\nimport WebinyError from \"@webiny/error\";\n\nconst parseValue = (value: any) => {\n if (String(value).match(/^0x/) !== null) {\n throw new WebinyError(\"Value sent must be a non-hex number.\", \"INVALID_VALUE\", {\n value\n });\n } else if (typeof value === \"number\") {\n return value;\n } else if (value === null || value === undefined) {\n return null;\n } else if (isNaN(value) === true) {\n throw new WebinyError(\"Value sent must be a number.\", \"INVALID_VALUE\", {\n value\n });\n }\n return parseFloat(value);\n};\n\nexport const NumberScalar = new GraphQLScalarType({\n name: \"Number\",\n description: \"A custom input type to be used with numbers. Supports Int and Float.\",\n serialize: (value: any) => {\n try {\n return parseValue(value);\n } catch (ex) {\n console.log({\n message: \"Value sent must be a number.\",\n code: \"INVALID_VALUE\",\n data: {\n value\n }\n });\n return null;\n }\n },\n parseValue,\n parseLiteral: ast => {\n if (ast.kind === Kind.INT) {\n return Number(ast.value);\n } else if (ast.kind === Kind.FLOAT) {\n return parseFloat(ast.value);\n }\n throw new Error(`Expected type Number, found {${ast.kind}}`);\n }\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,MAAMI,UAAU,GAAIC,KAAU,IAAK;EAC/B,IAAIC,MAAM,CAACD,KAAK,CAAC,CAACE,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;IACrC,MAAM,IAAIC,cAAW,CAAC,sCAAsC,EAAE,eAAe,EAAE;MAC3EH;IACJ,CAAC,CAAC;EACN,CAAC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAClC,OAAOA,KAAK;EAChB,CAAC,MAAM,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKI,SAAS,EAAE;IAC9C,OAAO,IAAI;EACf,CAAC,MAAM,IAAIC,KAAK,CAACL,KAAK,CAAC,KAAK,IAAI,EAAE;IAC9B,MAAM,IAAIG,cAAW,CAAC,8BAA8B,EAAE,eAAe,EAAE;MACnEH;IACJ,CAAC,CAAC;EACN;EACA,OAAOM,UAAU,CAACN,KAAK,CAAC;AAC5B,CAAC;AAEM,MAAMO,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,IAAIE,0BAAiB,CAAC;EAC9CC,IAAI,EAAE,QAAQ;EACdC,WAAW,EAAE,sEAAsE;EACnFC,SAAS,EAAGZ,KAAU,IAAK;IACvB,IAAI;MACA,OAAOD,UAAU,CAACC,KAAK,CAAC;IAC5B,CAAC,CAAC,OAAOa,EAAE,EAAE;MACTC,OAAO,CAACC,GAAG,CAAC;QACRC,OAAO,EAAE,8BAA8B;QACvCC,IAAI,EAAE,eAAe;QACrBC,IAAI,EAAE;UACFlB;QACJ;MACJ,CAAC,CAAC;MACF,OAAO,IAAI;IACf;EACJ,CAAC;EACDD,UAAU;EACVoB,YAAY,EAAEC,GAAG,IAAI;IACjB,IAAIA,GAAG,CAACC,IAAI,KAAKC,cAAI,CAACC,GAAG,EAAE;MACvB,OAAOC,MAAM,CAACJ,GAAG,CAACpB,KAAK,CAAC;IAC5B,CAAC,MAAM,IAAIoB,GAAG,CAACC,IAAI,KAAKC,cAAI,CAACG,KAAK,EAAE;MAChC,OAAOnB,UAAU,CAACc,GAAG,CAACpB,KAAK,CAAC;IAChC;IACA,MAAM,IAAI0B,KAAK,
|
|
1
|
+
{"version":3,"names":["_graphql","require","_language","_error","_interopRequireDefault","parseValue","value","String","match","WebinyError","undefined","isNaN","parseFloat","NumberScalar","exports","GraphQLScalarType","name","description","serialize","ex","console","log","message","code","data","parseLiteral","ast","kind","Kind","INT","Number","FLOAT","Error"],"sources":["NumberScalar.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\nimport { Kind } from \"graphql/language\";\nimport WebinyError from \"@webiny/error\";\n\nconst parseValue = (value: any) => {\n if (String(value).match(/^0x/) !== null) {\n throw new WebinyError(\"Value sent must be a non-hex number.\", \"INVALID_VALUE\", {\n value\n });\n } else if (typeof value === \"number\") {\n return value;\n } else if (value === null || value === undefined) {\n return null;\n } else if (isNaN(value) === true) {\n throw new WebinyError(\"Value sent must be a number.\", \"INVALID_VALUE\", {\n value\n });\n }\n return parseFloat(value);\n};\n\nexport const NumberScalar = new GraphQLScalarType({\n name: \"Number\",\n description: \"A custom input type to be used with numbers. Supports Int and Float.\",\n serialize: (value: any) => {\n try {\n return parseValue(value);\n } catch (ex) {\n console.log({\n message: \"Value sent must be a number.\",\n code: \"INVALID_VALUE\",\n data: {\n value\n }\n });\n return null;\n }\n },\n parseValue,\n parseLiteral: ast => {\n if (ast.kind === Kind.INT) {\n return Number(ast.value);\n } else if (ast.kind === Kind.FLOAT) {\n return parseFloat(ast.value);\n }\n throw new Error(`Expected type Number, found {${ast.kind}}`);\n }\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,MAAMI,UAAU,GAAIC,KAAU,IAAK;EAC/B,IAAIC,MAAM,CAACD,KAAK,CAAC,CAACE,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;IACrC,MAAM,IAAIC,cAAW,CAAC,sCAAsC,EAAE,eAAe,EAAE;MAC3EH;IACJ,CAAC,CAAC;EACN,CAAC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAClC,OAAOA,KAAK;EAChB,CAAC,MAAM,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKI,SAAS,EAAE;IAC9C,OAAO,IAAI;EACf,CAAC,MAAM,IAAIC,KAAK,CAACL,KAAK,CAAC,KAAK,IAAI,EAAE;IAC9B,MAAM,IAAIG,cAAW,CAAC,8BAA8B,EAAE,eAAe,EAAE;MACnEH;IACJ,CAAC,CAAC;EACN;EACA,OAAOM,UAAU,CAACN,KAAK,CAAC;AAC5B,CAAC;AAEM,MAAMO,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,IAAIE,0BAAiB,CAAC;EAC9CC,IAAI,EAAE,QAAQ;EACdC,WAAW,EAAE,sEAAsE;EACnFC,SAAS,EAAGZ,KAAU,IAAK;IACvB,IAAI;MACA,OAAOD,UAAU,CAACC,KAAK,CAAC;IAC5B,CAAC,CAAC,OAAOa,EAAE,EAAE;MACTC,OAAO,CAACC,GAAG,CAAC;QACRC,OAAO,EAAE,8BAA8B;QACvCC,IAAI,EAAE,eAAe;QACrBC,IAAI,EAAE;UACFlB;QACJ;MACJ,CAAC,CAAC;MACF,OAAO,IAAI;IACf;EACJ,CAAC;EACDD,UAAU;EACVoB,YAAY,EAAEC,GAAG,IAAI;IACjB,IAAIA,GAAG,CAACC,IAAI,KAAKC,cAAI,CAACC,GAAG,EAAE;MACvB,OAAOC,MAAM,CAACJ,GAAG,CAACpB,KAAK,CAAC;IAC5B,CAAC,MAAM,IAAIoB,GAAG,CAACC,IAAI,KAAKC,cAAI,CAACG,KAAK,EAAE;MAChC,OAAOnB,UAAU,CAACc,GAAG,CAACpB,KAAK,CAAC;IAChC;IACA,MAAM,IAAI0B,KAAK,CAAC,gCAAgCN,GAAG,CAACC,IAAI,GAAG,CAAC;EAChE;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphql","require","_error","_interopRequireDefault","re","parseTime","value","match","WebinyError","parsed","split","map","Number","length","hours","minutes","seconds","convertToTime","String","padStart","TimeScalar","exports","GraphQLScalarType","name","description","serialize","parseValue"],"sources":["TimeScalar.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\nimport WebinyError from \"@webiny/error\";\n\nconst re = /^([0-9]{2}):([0-9]{2})(:([0-9]{2}))?$/;\n\nconst parseTime = (value?: string) => {\n if (!value || value.match(re) === null) {\n throw new WebinyError(\"Value does not look like time.\", \"TIME_VALIDATION_ERROR\", { value });\n }\n const parsed = value.split(\":\").map(Number);\n if (parsed.length < 2) {\n throw new WebinyError(`Could not parse the value.`, \"TIME_VALIDATION_ERROR\", { value });\n }\n const [hours, minutes, seconds = 0] = parsed;\n if (hours >= 24) {\n throw new WebinyError(`There cannot be more than 24 hours.`, \"TIME_VALIDATION_ERROR\", {\n value\n });\n } else if (minutes >= 60) {\n throw new WebinyError(`There cannot be more than 59 minutes.`, \"TIME_VALIDATION_ERROR\", {\n value\n });\n } else if (seconds >= 60) {\n throw new WebinyError(`There cannot be more than 59 seconds.`, \"TIME_VALIDATION_ERROR\", {\n value\n });\n }\n return {\n hours,\n minutes,\n seconds\n };\n};\n\nconst convertToTime = (value: string): string => {\n const { hours, minutes, seconds } = parseTime(value);\n return `${String(hours).padStart(2, \"0\")}:${String(minutes).padStart(2, \"0\")}:${String(\n seconds\n ).padStart(2, \"0\")}`;\n};\n\nexport const TimeScalar = new GraphQLScalarType({\n name: \"Time\",\n description: \"A custom type to support time-only input.\",\n // sending to client\n serialize: convertToTime,\n // received from client\n parseValue: convertToTime\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,MAAMG,EAAE,GAAG,uCAAuC;AAElD,MAAMC,SAAS,GAAIC,KAAc,IAAK;EAClC,IAAI,CAACA,KAAK,IAAIA,KAAK,CAACC,KAAK,CAACH,EAAE,CAAC,KAAK,IAAI,EAAE;IACpC,MAAM,IAAII,cAAW,CAAC,gCAAgC,EAAE,uBAAuB,EAAE;MAAEF;IAAM,CAAC,CAAC;EAC/F;EACA,MAAMG,MAAM,GAAGH,KAAK,CAACI,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;EAC3C,IAAIH,MAAM,CAACI,MAAM,GAAG,CAAC,EAAE;IACnB,MAAM,IAAIL,cAAW,
|
|
1
|
+
{"version":3,"names":["_graphql","require","_error","_interopRequireDefault","re","parseTime","value","match","WebinyError","parsed","split","map","Number","length","hours","minutes","seconds","convertToTime","String","padStart","TimeScalar","exports","GraphQLScalarType","name","description","serialize","parseValue"],"sources":["TimeScalar.ts"],"sourcesContent":["import { GraphQLScalarType } from \"graphql\";\nimport WebinyError from \"@webiny/error\";\n\nconst re = /^([0-9]{2}):([0-9]{2})(:([0-9]{2}))?$/;\n\nconst parseTime = (value?: string) => {\n if (!value || value.match(re) === null) {\n throw new WebinyError(\"Value does not look like time.\", \"TIME_VALIDATION_ERROR\", { value });\n }\n const parsed = value.split(\":\").map(Number);\n if (parsed.length < 2) {\n throw new WebinyError(`Could not parse the value.`, \"TIME_VALIDATION_ERROR\", { value });\n }\n const [hours, minutes, seconds = 0] = parsed;\n if (hours >= 24) {\n throw new WebinyError(`There cannot be more than 24 hours.`, \"TIME_VALIDATION_ERROR\", {\n value\n });\n } else if (minutes >= 60) {\n throw new WebinyError(`There cannot be more than 59 minutes.`, \"TIME_VALIDATION_ERROR\", {\n value\n });\n } else if (seconds >= 60) {\n throw new WebinyError(`There cannot be more than 59 seconds.`, \"TIME_VALIDATION_ERROR\", {\n value\n });\n }\n return {\n hours,\n minutes,\n seconds\n };\n};\n\nconst convertToTime = (value: string): string => {\n const { hours, minutes, seconds } = parseTime(value);\n return `${String(hours).padStart(2, \"0\")}:${String(minutes).padStart(2, \"0\")}:${String(\n seconds\n ).padStart(2, \"0\")}`;\n};\n\nexport const TimeScalar = new GraphQLScalarType({\n name: \"Time\",\n description: \"A custom type to support time-only input.\",\n // sending to client\n serialize: convertToTime,\n // received from client\n parseValue: convertToTime\n});\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,MAAMG,EAAE,GAAG,uCAAuC;AAElD,MAAMC,SAAS,GAAIC,KAAc,IAAK;EAClC,IAAI,CAACA,KAAK,IAAIA,KAAK,CAACC,KAAK,CAACH,EAAE,CAAC,KAAK,IAAI,EAAE;IACpC,MAAM,IAAII,cAAW,CAAC,gCAAgC,EAAE,uBAAuB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CAAAD,UAAA,GAAG,IAAIE,0BAAiB,CAAC;EAC5CC,IAAI,EAAE,MAAM;EACZC,WAAW,EAAE,2CAA2C;EACxD;EACAC,SAAS,EAAER,aAAa;EACxB;EACAS,UAAU,EAAET;AAChB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -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","debugPlugins","exports","default"],"sources":["createGraphQLHandler.ts"],"sourcesContent":["import { boolean } from \"boolean\";\nimport { GraphQLSchema } from \"graphql\";\nimport { Context, RoutePlugin } from \"@webiny/handler\";\nimport WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { 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 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,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAGA,IAAAI,oBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AAEA,MAAMO,qBAAqB,GAAG,QAAQ,CAAC,CAAC;;AAExC,MAAMC,cAAc,GAAIC,OAAgB,IAAK;EACzC,MAAMC,OAAO,GAAG,IAAAC,qCAAgB,EAACF,OAAO,CAAC;EACzC;EACA;;EAEA;EACA;EACA,MAAMG,MAAM,GAAGH,OAAO,CAACI,OAAO,EAAEC,gBAAgB,CAAC,CAAC;;EAElD;EACA;EACA,MAAMC,aAAa,GAAGN,OAAO,CAACO,IAAI,EAAEC,gBAAgB,CAAC,CAAC;EAEtD,OAAO,CACHL,MAAM,
|
|
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","debugPlugins","exports","default"],"sources":["createGraphQLHandler.ts"],"sourcesContent":["import { boolean } from \"boolean\";\nimport { GraphQLSchema } from \"graphql\";\nimport { Context, RoutePlugin } from \"@webiny/handler\";\nimport WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { 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 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,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAGA,IAAAI,oBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AAEA,MAAMO,qBAAqB,GAAG,QAAQ,CAAC,CAAC;;AAExC,MAAMC,cAAc,GAAIC,OAAgB,IAAK;EACzC,MAAMC,OAAO,GAAG,IAAAC,qCAAgB,EAACF,OAAO,CAAC;EACzC;EACA;;EAEA;EACA;EACA,MAAMG,MAAM,GAAGH,OAAO,CAACI,OAAO,EAAEC,gBAAgB,CAAC,CAAC;;EAElD;EACA;EACA,MAAMC,aAAa,GAAGN,OAAO,CAACO,IAAI,EAAEC,gBAAgB,CAAC,CAAC;EAEtD,OAAO,CACHL,MAAM,GAAG,UAAUA,MAAM,CAACM,EAAE,EAAE,GAAG,IAAI,EACrCH,aAAa,GAAG,UAAUA,aAAa,CAACI,IAAI,EAAE,GAAG,IAAI,EACrDT,OAAO,CAACU,MAAM,CAACC,QAAQ,CAAC,CAAC,CAC5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AEFb,KAAK,CAACV,IAAI,GAAG,+BAA+B;EAE5C,OAAO,CACH,IAAIO,KAAK,GAAG,IAAAoB,qBAAY,EAAC,CAAC,GAAG,EAAE,CAAC,EAChC;IACI9B,IAAI,EAAE;EACV,CAAC,EACDa,KAAK,CACR;AACL,CAAC;AAAAkB,OAAA,CAAAC,OAAA,GAAA3B,QAAA","ignoreList":[]}
|
package/createGraphQLSchema.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLSchemaPlugin } from "./types";
|
|
2
1
|
import { Context } from "@webiny/api/types";
|
|
2
|
+
import { 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;
|
package/createGraphQLSchema.js
CHANGED
|
@@ -11,7 +11,12 @@ var _merge = require("@graphql-tools/merge");
|
|
|
11
11
|
var _builtInTypes = require("./builtInTypes");
|
|
12
12
|
var _ResolverDecoration = require("./ResolverDecoration");
|
|
13
13
|
const getSchemaPlugins = context => {
|
|
14
|
-
return context.plugins.byType("graphql-schema")
|
|
14
|
+
return context.plugins.byType("graphql-schema").filter(pl => {
|
|
15
|
+
if (typeof pl.isApplicable === "function") {
|
|
16
|
+
return pl.isApplicable(context);
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
});
|
|
15
20
|
};
|
|
16
21
|
exports.getSchemaPlugins = getSchemaPlugins;
|
|
17
22
|
const createGraphQLSchema = context => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphqlTag","_interopRequireDefault","require","_schema","_merge","_builtInTypes","_ResolverDecoration","getSchemaPlugins","context","plugins","byType","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,
|
|
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 ];\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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AMC,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":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/handler-graphql",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.42.0-beta.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -14,30 +14,26 @@
|
|
|
14
14
|
"Adrian Smijulj <adrian@webiny.com>"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@babel/runtime": "7.24.1",
|
|
18
17
|
"@graphql-tools/merge": "9.0.8",
|
|
19
18
|
"@graphql-tools/resolvers-composition": "7.0.2",
|
|
20
19
|
"@graphql-tools/schema": "10.0.7",
|
|
21
20
|
"@graphql-tools/utils": "10.5.5",
|
|
22
|
-
"@webiny/api": "5.
|
|
23
|
-
"@webiny/error": "5.
|
|
24
|
-
"@webiny/handler": "5.
|
|
25
|
-
"@webiny/plugins": "5.
|
|
21
|
+
"@webiny/api": "5.42.0-beta.1",
|
|
22
|
+
"@webiny/error": "5.42.0-beta.1",
|
|
23
|
+
"@webiny/handler": "5.42.0-beta.1",
|
|
24
|
+
"@webiny/plugins": "5.42.0-beta.1",
|
|
26
25
|
"boolean": "3.2.0",
|
|
27
|
-
"graphql": "15.
|
|
26
|
+
"graphql": "15.9.0",
|
|
28
27
|
"graphql-scalars": "1.12.0",
|
|
29
28
|
"graphql-tag": "2.12.6"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
-
"@webiny/cli": "5.41.4",
|
|
36
|
-
"@webiny/handler-aws": "5.41.4",
|
|
37
|
-
"@webiny/project-utils": "5.41.4",
|
|
31
|
+
"@webiny/cli": "5.42.0-beta.1",
|
|
32
|
+
"@webiny/handler-aws": "5.42.0-beta.1",
|
|
33
|
+
"@webiny/project-utils": "5.42.0-beta.1",
|
|
38
34
|
"jest": "29.7.0",
|
|
39
|
-
"jest-mock-console": "
|
|
40
|
-
"rimraf": "
|
|
35
|
+
"jest-mock-console": "2.0.0",
|
|
36
|
+
"rimraf": "6.0.1",
|
|
41
37
|
"ttypescript": "1.5.15",
|
|
42
38
|
"typescript": "4.9.5"
|
|
43
39
|
},
|
|
@@ -49,5 +45,5 @@
|
|
|
49
45
|
"build": "yarn webiny run build",
|
|
50
46
|
"watch": "yarn webiny run watch"
|
|
51
47
|
},
|
|
52
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "5e69da579efa4f2c8268e0c97ac6407ddc3f5f07"
|
|
53
49
|
}
|
package/processRequestBody.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExecutionResult, GraphQLSchema } from "graphql";
|
|
1
|
+
import type { ExecutionResult, GraphQLSchema } from "graphql";
|
|
2
2
|
import { GraphQLRequestBody } from "./types";
|
|
3
|
-
import { Context } from "@webiny/api/types";
|
|
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>[]>;
|
package/processRequestBody.js
CHANGED
|
@@ -16,7 +16,14 @@ const executeGraphQl = async (body, schema, context) => {
|
|
|
16
16
|
schema,
|
|
17
17
|
context
|
|
18
18
|
}));
|
|
19
|
-
const result = await (0, _graphql.graphql)(
|
|
19
|
+
const result = await (0, _graphql.graphql)({
|
|
20
|
+
schema,
|
|
21
|
+
source: query,
|
|
22
|
+
rootValue: {},
|
|
23
|
+
contextValue: context,
|
|
24
|
+
variableValues: variables,
|
|
25
|
+
operationName
|
|
26
|
+
});
|
|
20
27
|
context.plugins.byType("graphql-after-query").forEach(pl => {
|
|
21
28
|
pl.apply({
|
|
22
29
|
result,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphql","require","executeGraphQl","body","schema","context","query","variables","operationName","plugins","byType","forEach","pl","apply","result","graphql","processRequestBody","requestBody","Array","isArray","results","push","exports"],"sources":["processRequestBody.ts"],"sourcesContent":["import { ExecutionResult, graphql
|
|
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 { GraphQLAfterQueryPlugin, GraphQLBeforeQueryPlugin, GraphQLRequestBody } 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,QAAA,GAAAC,OAAA;AAIA,MAAMC,cAAc,GAAG,MAAAA,CACnBC,IAAwB,EACxBC,MAAqB,EACrBC,OAAgB,KAC+B;EAC/C,MAAM;IAAEC,KAAK;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGL,IAAI;EAEhDE,OAAO,CAACI,OAAO,CACVC,MAAM,CAA2B,sBAAsB,CAAC,CACxDC,OAAO,CAACC,EAAE,IAAIA,EAAE,CAACC,KAAK,CAAC;IAAEV,IAAI;IAAEC,MAAM;IAAEC;EAAQ,CAAC,CAAC,CAAC;EAEvD,MAAMS,MAAM,GAAG,MAAM,IAAAC,gBAAO,EAAC;IACzBX,MAAM;IACNY,MAAM,EAAEV,KAAK;I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