graphile-build-pg 4.9.1 → 4.11.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.
Files changed (76) hide show
  1. package/README.md +1 -0
  2. package/node8plus/plugins/PageInfoStartEndCursor.js +2 -2
  3. package/node8plus/plugins/PageInfoStartEndCursor.js.flow +6 -2
  4. package/node8plus/plugins/PageInfoStartEndCursor.js.map +1 -1
  5. package/node8plus/plugins/PgAllRows.js +1 -1
  6. package/node8plus/plugins/PgAllRows.js.flow +6 -3
  7. package/node8plus/plugins/PgAllRows.js.map +1 -1
  8. package/node8plus/plugins/PgBackwardRelationPlugin.js +2 -2
  9. package/node8plus/plugins/PgBackwardRelationPlugin.js.flow +8 -2
  10. package/node8plus/plugins/PgBackwardRelationPlugin.js.map +1 -1
  11. package/node8plus/plugins/PgBasicsPlugin.js +1 -1
  12. package/node8plus/plugins/PgBasicsPlugin.js.flow +1 -1
  13. package/node8plus/plugins/PgBasicsPlugin.js.map +1 -1
  14. package/node8plus/plugins/PgConditionComputedColumnPlugin.js +1 -1
  15. package/node8plus/plugins/PgConditionComputedColumnPlugin.js.flow +4 -1
  16. package/node8plus/plugins/PgConditionComputedColumnPlugin.js.map +1 -1
  17. package/node8plus/plugins/PgConnectionArgCondition.js +3 -3
  18. package/node8plus/plugins/PgConnectionArgCondition.js.flow +11 -3
  19. package/node8plus/plugins/PgConnectionArgCondition.js.map +1 -1
  20. package/node8plus/plugins/PgConnectionArgFirstLastBeforeAfter.js +5 -5
  21. package/node8plus/plugins/PgConnectionArgFirstLastBeforeAfter.js.flow +20 -7
  22. package/node8plus/plugins/PgConnectionArgFirstLastBeforeAfter.js.map +1 -1
  23. package/node8plus/plugins/PgConnectionArgOrderBy.js +2 -2
  24. package/node8plus/plugins/PgConnectionArgOrderBy.js.flow +8 -2
  25. package/node8plus/plugins/PgConnectionArgOrderBy.js.map +1 -1
  26. package/node8plus/plugins/PgConnectionTotalCount.js +1 -1
  27. package/node8plus/plugins/PgConnectionTotalCount.js.flow +4 -1
  28. package/node8plus/plugins/PgConnectionTotalCount.js.map +1 -1
  29. package/node8plus/plugins/PgForwardRelationPlugin.js +1 -1
  30. package/node8plus/plugins/PgForwardRelationPlugin.js.flow +4 -1
  31. package/node8plus/plugins/PgForwardRelationPlugin.js.map +1 -1
  32. package/node8plus/plugins/PgIntrospectionPlugin.d.ts +1 -0
  33. package/node8plus/plugins/PgIntrospectionPlugin.js +182 -159
  34. package/node8plus/plugins/PgIntrospectionPlugin.js.flow +218 -198
  35. package/node8plus/plugins/PgIntrospectionPlugin.js.map +1 -1
  36. package/node8plus/plugins/PgJWTPlugin.js +1 -1
  37. package/node8plus/plugins/PgJWTPlugin.js.flow +3 -1
  38. package/node8plus/plugins/PgJWTPlugin.js.map +1 -1
  39. package/node8plus/plugins/PgMutationCreatePlugin.js +7 -7
  40. package/node8plus/plugins/PgMutationCreatePlugin.js.flow +26 -7
  41. package/node8plus/plugins/PgMutationCreatePlugin.js.map +1 -1
  42. package/node8plus/plugins/PgMutationPayloadEdgePlugin.js +2 -2
  43. package/node8plus/plugins/PgMutationPayloadEdgePlugin.js.flow +8 -2
  44. package/node8plus/plugins/PgMutationPayloadEdgePlugin.js.map +1 -1
  45. package/node8plus/plugins/PgMutationUpdateDeletePlugin.js +11 -11
  46. package/node8plus/plugins/PgMutationUpdateDeletePlugin.js.flow +40 -11
  47. package/node8plus/plugins/PgMutationUpdateDeletePlugin.js.map +1 -1
  48. package/node8plus/plugins/PgRecordFunctionConnectionPlugin.js +6 -6
  49. package/node8plus/plugins/PgRecordFunctionConnectionPlugin.js.flow +24 -6
  50. package/node8plus/plugins/PgRecordFunctionConnectionPlugin.js.map +1 -1
  51. package/node8plus/plugins/PgRecordReturnTypesPlugin.js +1 -1
  52. package/node8plus/plugins/PgRecordReturnTypesPlugin.js.flow +6 -3
  53. package/node8plus/plugins/PgRecordReturnTypesPlugin.js.map +1 -1
  54. package/node8plus/plugins/PgRowNode.js +2 -2
  55. package/node8plus/plugins/PgRowNode.js.flow +8 -2
  56. package/node8plus/plugins/PgRowNode.js.map +1 -1
  57. package/node8plus/plugins/PgScalarFunctionConnectionPlugin.js +6 -6
  58. package/node8plus/plugins/PgScalarFunctionConnectionPlugin.js.flow +24 -6
  59. package/node8plus/plugins/PgScalarFunctionConnectionPlugin.js.map +1 -1
  60. package/node8plus/plugins/PgTablesPlugin.js +13 -13
  61. package/node8plus/plugins/PgTablesPlugin.js.flow +56 -20
  62. package/node8plus/plugins/PgTablesPlugin.js.map +1 -1
  63. package/node8plus/plugins/PgTypesPlugin.js +62 -78
  64. package/node8plus/plugins/PgTypesPlugin.js.flow +193 -76
  65. package/node8plus/plugins/PgTypesPlugin.js.map +1 -1
  66. package/node8plus/plugins/makeProcField.js +3 -3
  67. package/node8plus/plugins/makeProcField.js.flow +16 -7
  68. package/node8plus/plugins/makeProcField.js.map +1 -1
  69. package/node8plus/plugins/viaTemporaryTable.js +1 -1
  70. package/node8plus/plugins/viaTemporaryTable.js.flow +8 -4
  71. package/node8plus/plugins/viaTemporaryTable.js.map +1 -1
  72. package/node8plus/postgresInterval.js +12 -33
  73. package/node8plus/postgresInterval.js.flow +22 -51
  74. package/node8plus/postgresInterval.js.map +1 -1
  75. package/package.json +9 -9
  76. package/res/watch-fixtures.sql +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/PgMutationCreatePlugin.js"],"names":["debug","PgMutationCreatePlugin","builder","pgDisableDefaultMutations","hook","fields","build","context","extend","newWithHooks","parseResolveInfo","pgIntrospectionResultsByKind","pgGetGqlTypeByTypeIdAndModifier","pgGetGqlInputTypeByTypeIdAndModifier","pgSql","sql","gql2pg","graphql","GraphQLObjectType","GraphQLInputObjectType","GraphQLNonNull","GraphQLString","pgColumnFilter","inflection","pgQueryFromResolveData","queryFromResolveData","pgOmit","omit","pgViaTemporaryTable","viaTemporaryTable","describePgEntity","sqlCommentByAddingTags","pgField","scope","isRootMutation","fieldWithHooks","class","reduce","memo","table","namespace","isSelectable","isInsertable","Table","type","id","name","TableInput","tableTypeName","tableType","InputType","createInputType","description","clientMutationId","tableFieldName","__origin","isPgCreateInputType","pgInflection","pgIntrospection","PayloadType","createPayloadType","tableName","isPgCreatePayloadResultField","pgFieldIntrospection","isMutationPayload","isPgCreatePayloadType","fieldName","createField","getDataFromParsedResolveInfoFragment","relevantAttributes","attributes","filter","attr","args","input","resolve","data","resolveContext","resolveInfo","pgClient","parsedResolveInfoFragment","resolveData","insertedRowAlias","identifier","Symbol","query","rootValue","sqlColumns","sqlValues","inputData","forEach","column","val","Object","prototype","hasOwnProperty","call","push","typeModifier","mutationQuery","length","fragment","join","row","rows","e","isPgCreateMutationField"],"mappings":";;;;;;;AAEA;;;;AAEA,MAAMA,KAAK,GAAG,oBAAa,mBAAb,CAAd;;IAEyBC,sB,GAAT,SAASA,sBAAT,CACdC,OADc,EAEd;AAAEC,EAAAA;AAAF,CAFc,EAGd;AACA,MAAIA,yBAAJ,EAA+B;AAC7B;AACD;;AAEDD,EAAAA,OAAO,CAACE,IAAR,CACE,0BADF,EAEE,CAACC,MAAD,EAASC,KAAT,EAAgBC,OAAhB,KAA4B;AAC1B,UAAM;AACJC,MAAAA,MADI;AAEJC,MAAAA,YAFI;AAGJC,MAAAA,gBAHI;AAIJC,MAAAA,4BAJI;AAKJC,MAAAA,+BALI;AAMJC,MAAAA,oCANI;AAOJC,MAAAA,KAAK,EAAEC,GAPH;AAQJC,MAAAA,MARI;AASJC,MAAAA,OAAO,EAAE;AACPC,QAAAA,iBADO;AAEPC,QAAAA,sBAFO;AAGPC,QAAAA,cAHO;AAIPC,QAAAA;AAJO,OATL;AAeJC,MAAAA,cAfI;AAgBJC,MAAAA,UAhBI;AAiBJC,MAAAA,sBAAsB,EAAEC,oBAjBpB;AAkBJC,MAAAA,MAAM,EAAEC,IAlBJ;AAmBJC,MAAAA,mBAAmB,EAAEC,iBAnBjB;AAoBJC,MAAAA,gBApBI;AAqBJC,MAAAA,sBArBI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xB;AAEEmE,UAAAA,uBAAuB,EAAE;AAF3B,SA9FyB;AAD7B,OAFK,EAuGJ,8BAA6B5E,gBAAgB,CAC5CS,KAD4C,CAE5C,qEAAoER,sBAAsB,CAC1FQ,KAD0F,EAE1F;AACEZ,QAAAA,IAAI,EAAE;AADR,OAF0F,CAK1F,EA9GG,CAAP;AAgHA,aAAOW,IAAP;AACD,KA1ND,EA0NG,EA1NH,CAFW,EA6NV,mDA7NU,CAAb;AA+ND,GAnQH,EAoQE,CAAC,kBAAD,CApQF,EAqQE,EArQF,EAsQE,CAAC,UAAD,CAtQF;AAwQD,C","sourcesContent":["// @flow\nimport type { Plugin } from \"graphile-build\";\nimport debugFactory from \"debug\";\n\nconst debug = debugFactory(\"graphile-build-pg\");\n\nexport default (function PgMutationCreatePlugin(\n builder,\n { pgDisableDefaultMutations }\n) {\n if (pgDisableDefaultMutations) {\n return;\n }\n\n builder.hook(\n \"GraphQLObjectType:fields\",\n (fields, build, context) => {\n const {\n extend,\n newWithHooks,\n parseResolveInfo,\n pgIntrospectionResultsByKind,\n pgGetGqlTypeByTypeIdAndModifier,\n pgGetGqlInputTypeByTypeIdAndModifier,\n pgSql: sql,\n gql2pg,\n graphql: {\n GraphQLObjectType,\n GraphQLInputObjectType,\n GraphQLNonNull,\n GraphQLString,\n },\n pgColumnFilter,\n inflection,\n pgQueryFromResolveData: queryFromResolveData,\n pgOmit: omit,\n pgViaTemporaryTable: viaTemporaryTable,\n describePgEntity,\n sqlCommentByAddingTags,\n pgField,\n } = build;\n const {\n scope: { isRootMutation },\n fieldWithHooks,\n } = context;\n\n if (!isRootMutation) {\n return fields;\n }\n\n return extend(\n fields,\n pgIntrospectionResultsByKind.class.reduce((memo, table) => {\n // PERFORMANCE: These used to be .filter(...) calls\n if (!table.namespace) return memo;\n if (!table.isSelectable) return memo;\n if (!table.isInsertable || omit(table, \"create\")) return memo;\n\n const Table = pgGetGqlTypeByTypeIdAndModifier(table.type.id, null);\n if (!Table) {\n debug(\n `There was no table type for table '${table.namespace.name}.${table.name}', so we're not generating a create mutation for it.`\n );\n return memo;\n }\n const TableInput = pgGetGqlInputTypeByTypeIdAndModifier(\n table.type.id,\n null\n );\n if (!TableInput) {\n debug(\n `There was no input type for table '${table.namespace.name}.${table.name}', so we're going to omit it from the create mutation.`\n );\n }\n const tableTypeName = inflection.tableType(table);\n const InputType = newWithHooks(\n GraphQLInputObjectType,\n {\n name: inflection.createInputType(table),\n description: `All input for the create \\`${tableTypeName}\\` mutation.`,\n fields: {\n clientMutationId: {\n description:\n \"An arbitrary string value with no semantic meaning. Will be included in the payload verbatim. May be used to track mutations by the client.\",\n type: GraphQLString,\n },\n ...(TableInput\n ? {\n [inflection.tableFieldName(table)]: {\n description: `The \\`${tableTypeName}\\` to be created by this mutation.`,\n type: new GraphQLNonNull(TableInput),\n },\n }\n : null),\n },\n },\n {\n __origin: `Adding table create input type for ${describePgEntity(\n table\n )}. You can rename the table's GraphQL type via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n table,\n {\n name: \"newNameHere\",\n }\n )}`,\n isPgCreateInputType: true,\n pgInflection: table, // TODO:v5: remove - TYPO!\n pgIntrospection: table,\n }\n );\n const PayloadType = newWithHooks(\n GraphQLObjectType,\n {\n name: inflection.createPayloadType(table),\n description: `The output of our create \\`${tableTypeName}\\` mutation.`,\n fields: ({ fieldWithHooks }) => {\n const tableName = inflection.tableFieldName(table);\n return {\n clientMutationId: {\n description:\n \"The exact same `clientMutationId` that was provided in the mutation input, unchanged and unused. May be used by a client to track mutations.\",\n type: GraphQLString,\n },\n [tableName]: pgField(\n build,\n fieldWithHooks,\n tableName,\n {\n description: `The \\`${tableTypeName}\\` that was created by this mutation.`,\n type: Table,\n },\n {\n isPgCreatePayloadResultField: true,\n pgFieldIntrospection: table,\n }\n ),\n };\n },\n },\n {\n __origin: `Adding table create payload type for ${describePgEntity(\n table\n )}. You can rename the table's GraphQL type via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n table,\n {\n name: \"newNameHere\",\n }\n )}\\n\\nor disable the built-in create mutation via:\\n\\n ${sqlCommentByAddingTags(\n table,\n { omit: \"create\" }\n )}`,\n isMutationPayload: true,\n isPgCreatePayloadType: true,\n pgIntrospection: table,\n }\n );\n const fieldName = inflection.createField(table);\n memo = build.extend(\n memo,\n {\n [fieldName]: fieldWithHooks(\n fieldName,\n context => {\n const { getDataFromParsedResolveInfoFragment } = context;\n const relevantAttributes = table.attributes.filter(\n attr =>\n pgColumnFilter(attr, build, context) &&\n !omit(attr, \"create\")\n );\n return {\n description: `Creates a single \\`${tableTypeName}\\`.`,\n type: PayloadType,\n args: {\n input: {\n type: new GraphQLNonNull(InputType),\n },\n },\n async resolve(data, args, resolveContext, resolveInfo) {\n const { input } = args;\n const { pgClient } = resolveContext;\n const parsedResolveInfoFragment = parseResolveInfo(\n resolveInfo\n );\n parsedResolveInfoFragment.args = args; // Allow overriding via makeWrapResolversPlugin\n const resolveData = getDataFromParsedResolveInfoFragment(\n parsedResolveInfoFragment,\n PayloadType\n );\n const insertedRowAlias = sql.identifier(Symbol());\n const query = queryFromResolveData(\n insertedRowAlias,\n insertedRowAlias,\n resolveData,\n {},\n null,\n resolveContext,\n resolveInfo.rootValue\n );\n const sqlColumns = [];\n const sqlValues = [];\n const inputData = input[inflection.tableFieldName(table)];\n relevantAttributes.forEach(attr => {\n const fieldName = inflection.column(attr);\n const val = inputData[fieldName];\n if (\n Object.prototype.hasOwnProperty.call(\n inputData,\n fieldName\n )\n ) {\n sqlColumns.push(sql.identifier(attr.name));\n sqlValues.push(\n gql2pg(val, attr.type, attr.typeModifier)\n );\n }\n });\n\n const mutationQuery = sql.query`\\\ninsert into ${sql.identifier(table.namespace.name, table.name)} ${\n sqlColumns.length\n ? sql.fragment`(${sql.join(\n sqlColumns,\n \", \"\n )}) values(${sql.join(sqlValues, \", \")})`\n : sql.fragment`default values`\n } returning *`;\n\n let row;\n try {\n await pgClient.query(\"SAVEPOINT graphql_mutation\");\n const rows = await viaTemporaryTable(\n pgClient,\n sql.identifier(table.namespace.name, table.name),\n mutationQuery,\n insertedRowAlias,\n query\n );\n row = rows[0];\n await pgClient.query(\n \"RELEASE SAVEPOINT graphql_mutation\"\n );\n } catch (e) {\n await pgClient.query(\n \"ROLLBACK TO SAVEPOINT graphql_mutation\"\n );\n throw e;\n }\n return {\n clientMutationId: input.clientMutationId,\n data: row,\n };\n },\n };\n },\n {\n pgFieldIntrospection: table,\n isPgCreateMutationField: true,\n }\n ),\n },\n `Adding create mutation for ${describePgEntity(\n table\n )}. You can omit this default mutation with a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n table,\n {\n omit: \"create\",\n }\n )}`\n );\n return memo;\n }, {}),\n `Adding default 'create' mutation to root mutation`\n );\n },\n [\"PgMutationCreate\"],\n [],\n [\"PgTables\"]\n );\n}: Plugin);\n"],"file":"PgMutationCreatePlugin.js"}
1
+ {"version":3,"sources":["../../src/plugins/PgMutationCreatePlugin.js"],"names":["debug","PgMutationCreatePlugin","builder","pgDisableDefaultMutations","hook","fields","build","context","extend","newWithHooks","parseResolveInfo","pgIntrospectionResultsByKind","pgGetGqlTypeByTypeIdAndModifier","pgGetGqlInputTypeByTypeIdAndModifier","pgSql","sql","gql2pg","graphql","GraphQLObjectType","GraphQLInputObjectType","GraphQLNonNull","GraphQLString","pgColumnFilter","inflection","pgQueryFromResolveData","queryFromResolveData","pgOmit","omit","pgViaTemporaryTable","viaTemporaryTable","describePgEntity","sqlCommentByAddingTags","pgField","scope","isRootMutation","fieldWithHooks","class","reduce","memo","table","namespace","isSelectable","isInsertable","Table","type","id","name","TableInput","tableTypeName","tableType","InputType","createInputType","description","wrapDescription","clientMutationId","tableFieldName","__origin","isPgCreateInputType","pgInflection","pgIntrospection","PayloadType","createPayloadType","tableName","isPgCreatePayloadResultField","pgFieldIntrospection","isMutationPayload","isPgCreatePayloadType","fieldName","createField","getDataFromParsedResolveInfoFragment","relevantAttributes","attributes","filter","attr","args","input","resolve","data","resolveContext","resolveInfo","pgClient","parsedResolveInfoFragment","resolveData","insertedRowAlias","identifier","Symbol","query","rootValue","sqlColumns","sqlValues","inputData","forEach","column","val","Object","prototype","hasOwnProperty","call","push","typeModifier","mutationQuery","length","fragment","join","row","rows","e","isPgCreateMutationField"],"mappings":";;;;;;;AAEA;;;;AAEA,MAAMA,KAAK,GAAG,oBAAa,mBAAb,CAAd;;IAEyBC,sB,GAAT,SAASA,sBAAT,CACdC,OADc,EAEd;AAAEC,EAAAA;AAAF,CAFc,EAGd;AACA,MAAIA,yBAAJ,EAA+B;AAC7B;AACD;;AAEDD,EAAAA,OAAO,CAACE,IAAR,CACE,0BADF,EAEE,CAACC,MAAD,EAASC,KAAT,EAAgBC,OAAhB,KAA4B;AAC1B,UAAM;AACJC,MAAAA,MADI;AAEJC,MAAAA,YAFI;AAGJC,MAAAA,gBAHI;AAIJC,MAAAA,4BAJI;AAKJC,MAAAA,+BALI;AAMJC,MAAAA,oCANI;AAOJC,MAAAA,KAAK,EAAEC,GAPH;AAQJC,MAAAA,MARI;AASJC,MAAAA,OAAO,EAAE;AACPC,QAAAA,iBADO;AAEPC,QAAAA,sBAFO;AAGPC,QAAAA,cAHO;AAIPC,QAAAA;AAJO,OATL;AAeJC,MAAAA,cAfI;AAgBJC,MAAAA,UAhBI;AAiBJC,MAAAA,sBAAsB,EAAEC,oBAjBpB;AAkBJC,MAAAA,MAAM,EAAEC,IAlBJ;AAmBJC,MAAAA,mBAAmB,EAAEC,iBAnBjB;AAoBJC,MAAAA,gBApBI;AAqBJC,MAAAA,sBArBI;AAsBJC,MAAAA;AAtBI,QAuBF1B,KAvBJ;AAwBA,UAAM;AACJ2B,MAAAA,KAAK,EAAE;AAAEC,QAAAA;AAAF,OADH;AAEJC,MAAAA;AAFI,QAGF5B,OAHJ;;AAKA,QAAI,CAAC2B,cAAL,EAAqB;AACnB,aAAO7B,MAAP;AACD;;AAED,WAAOG,MAAM,CACXH,MADW,EAEXM,4BAA4B,CAACyB,KAA7B,CAA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C,UAAAA,oBAAoB,EAAEzB,KADxB;AAEEoE,UAAAA,uBAAuB,EAAE;AAF3B,SAjGyB;AAD7B,OAFK,EA0GJ,8BAA6B7E,gBAAgB,CAC5CS,KAD4C,CAE5C,qEAAoER,sBAAsB,CAC1FQ,KAD0F,EAE1F;AACEZ,QAAAA,IAAI,EAAE;AADR,OAF0F,CAK1F,EAjHG,CAAP;AAmHA,aAAOW,IAAP;AACD,KA7OD,EA6OG,EA7OH,CAFW,EAgPV,mDAhPU,CAAb;AAkPD,GAtRH,EAuRE,CAAC,kBAAD,CAvRF,EAwRE,EAxRF,EAyRE,CAAC,UAAD,CAzRF;AA2RD,C","sourcesContent":["// @flow\nimport type { Plugin } from \"graphile-build\";\nimport debugFactory from \"debug\";\n\nconst debug = debugFactory(\"graphile-build-pg\");\n\nexport default (function PgMutationCreatePlugin(\n builder,\n { pgDisableDefaultMutations }\n) {\n if (pgDisableDefaultMutations) {\n return;\n }\n\n builder.hook(\n \"GraphQLObjectType:fields\",\n (fields, build, context) => {\n const {\n extend,\n newWithHooks,\n parseResolveInfo,\n pgIntrospectionResultsByKind,\n pgGetGqlTypeByTypeIdAndModifier,\n pgGetGqlInputTypeByTypeIdAndModifier,\n pgSql: sql,\n gql2pg,\n graphql: {\n GraphQLObjectType,\n GraphQLInputObjectType,\n GraphQLNonNull,\n GraphQLString,\n },\n pgColumnFilter,\n inflection,\n pgQueryFromResolveData: queryFromResolveData,\n pgOmit: omit,\n pgViaTemporaryTable: viaTemporaryTable,\n describePgEntity,\n sqlCommentByAddingTags,\n pgField,\n } = build;\n const {\n scope: { isRootMutation },\n fieldWithHooks,\n } = context;\n\n if (!isRootMutation) {\n return fields;\n }\n\n return extend(\n fields,\n pgIntrospectionResultsByKind.class.reduce((memo, table) => {\n // PERFORMANCE: These used to be .filter(...) calls\n if (!table.namespace) return memo;\n if (!table.isSelectable) return memo;\n if (!table.isInsertable || omit(table, \"create\")) return memo;\n\n const Table = pgGetGqlTypeByTypeIdAndModifier(table.type.id, null);\n if (!Table) {\n debug(\n `There was no table type for table '${table.namespace.name}.${table.name}', so we're not generating a create mutation for it.`\n );\n return memo;\n }\n const TableInput = pgGetGqlInputTypeByTypeIdAndModifier(\n table.type.id,\n null\n );\n if (!TableInput) {\n debug(\n `There was no input type for table '${table.namespace.name}.${table.name}', so we're going to omit it from the create mutation.`\n );\n }\n const tableTypeName = inflection.tableType(table);\n const InputType = newWithHooks(\n GraphQLInputObjectType,\n {\n name: inflection.createInputType(table),\n description: build.wrapDescription(\n `All input for the create \\`${tableTypeName}\\` mutation.`,\n \"type\"\n ),\n fields: {\n clientMutationId: {\n description: build.wrapDescription(\n \"An arbitrary string value with no semantic meaning. Will be included in the payload verbatim. May be used to track mutations by the client.\",\n \"field\"\n ),\n type: GraphQLString,\n },\n ...(TableInput\n ? {\n [inflection.tableFieldName(table)]: {\n description: build.wrapDescription(\n `The \\`${tableTypeName}\\` to be created by this mutation.`,\n \"field\"\n ),\n type: new GraphQLNonNull(TableInput),\n },\n }\n : null),\n },\n },\n {\n __origin: `Adding table create input type for ${describePgEntity(\n table\n )}. You can rename the table's GraphQL type via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n table,\n {\n name: \"newNameHere\",\n }\n )}`,\n isPgCreateInputType: true,\n pgInflection: table, // TODO:v5: remove - TYPO!\n pgIntrospection: table,\n }\n );\n const PayloadType = newWithHooks(\n GraphQLObjectType,\n {\n name: inflection.createPayloadType(table),\n description: build.wrapDescription(\n `The output of our create \\`${tableTypeName}\\` mutation.`,\n \"type\"\n ),\n fields: ({ fieldWithHooks }) => {\n const tableName = inflection.tableFieldName(table);\n return {\n clientMutationId: {\n description: build.wrapDescription(\n \"The exact same `clientMutationId` that was provided in the mutation input, unchanged and unused. May be used by a client to track mutations.\",\n \"field\"\n ),\n type: GraphQLString,\n },\n [tableName]: pgField(\n build,\n fieldWithHooks,\n tableName,\n {\n description: build.wrapDescription(\n `The \\`${tableTypeName}\\` that was created by this mutation.`,\n \"field\"\n ),\n type: Table,\n },\n {\n isPgCreatePayloadResultField: true,\n pgFieldIntrospection: table,\n }\n ),\n };\n },\n },\n {\n __origin: `Adding table create payload type for ${describePgEntity(\n table\n )}. You can rename the table's GraphQL type via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n table,\n {\n name: \"newNameHere\",\n }\n )}\\n\\nor disable the built-in create mutation via:\\n\\n ${sqlCommentByAddingTags(\n table,\n { omit: \"create\" }\n )}`,\n isMutationPayload: true,\n isPgCreatePayloadType: true,\n pgIntrospection: table,\n }\n );\n const fieldName = inflection.createField(table);\n memo = build.extend(\n memo,\n {\n [fieldName]: fieldWithHooks(\n fieldName,\n context => {\n const { getDataFromParsedResolveInfoFragment } = context;\n const relevantAttributes = table.attributes.filter(\n attr =>\n pgColumnFilter(attr, build, context) &&\n !omit(attr, \"create\")\n );\n return {\n description: build.wrapDescription(\n `Creates a single \\`${tableTypeName}\\`.`,\n \"field\"\n ),\n type: PayloadType,\n args: {\n input: {\n type: new GraphQLNonNull(InputType),\n },\n },\n async resolve(data, args, resolveContext, resolveInfo) {\n const { input } = args;\n const { pgClient } = resolveContext;\n const parsedResolveInfoFragment = parseResolveInfo(\n resolveInfo\n );\n parsedResolveInfoFragment.args = args; // Allow overriding via makeWrapResolversPlugin\n const resolveData = getDataFromParsedResolveInfoFragment(\n parsedResolveInfoFragment,\n PayloadType\n );\n const insertedRowAlias = sql.identifier(Symbol());\n const query = queryFromResolveData(\n insertedRowAlias,\n insertedRowAlias,\n resolveData,\n {},\n null,\n resolveContext,\n resolveInfo.rootValue\n );\n const sqlColumns = [];\n const sqlValues = [];\n const inputData = input[inflection.tableFieldName(table)];\n relevantAttributes.forEach(attr => {\n const fieldName = inflection.column(attr);\n const val = inputData[fieldName];\n if (\n Object.prototype.hasOwnProperty.call(\n inputData,\n fieldName\n )\n ) {\n sqlColumns.push(sql.identifier(attr.name));\n sqlValues.push(\n gql2pg(val, attr.type, attr.typeModifier)\n );\n }\n });\n\n const mutationQuery = sql.query`\\\ninsert into ${sql.identifier(table.namespace.name, table.name)} ${\n sqlColumns.length\n ? sql.fragment`(${sql.join(\n sqlColumns,\n \", \"\n )}) values(${sql.join(sqlValues, \", \")})`\n : sql.fragment`default values`\n } returning *`;\n\n let row;\n try {\n await pgClient.query(\"SAVEPOINT graphql_mutation\");\n const rows = await viaTemporaryTable(\n pgClient,\n sql.identifier(table.namespace.name, table.name),\n mutationQuery,\n insertedRowAlias,\n query\n );\n row = rows[0];\n await pgClient.query(\n \"RELEASE SAVEPOINT graphql_mutation\"\n );\n } catch (e) {\n await pgClient.query(\n \"ROLLBACK TO SAVEPOINT graphql_mutation\"\n );\n throw e;\n }\n return {\n clientMutationId: input.clientMutationId,\n data: row,\n };\n },\n };\n },\n {\n pgFieldIntrospection: table,\n isPgCreateMutationField: true,\n }\n ),\n },\n `Adding create mutation for ${describePgEntity(\n table\n )}. You can omit this default mutation with a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n table,\n {\n omit: \"create\",\n }\n )}`\n );\n return memo;\n }, {}),\n `Adding default 'create' mutation to root mutation`\n );\n },\n [\"PgMutationCreate\"],\n [],\n [\"PgTables\"]\n );\n}: Plugin);\n"],"file":"PgMutationCreatePlugin.js"}
@@ -71,11 +71,11 @@ var PgMutationPayloadEdgePlugin = function PgMutationPayloadEdgePlugin(builder,
71
71
  const defaultValueEnum = canOrderBy && (TableOrderByType.getValues().find(v => v.name === "PRIMARY_KEY_ASC") || TableOrderByType.getValues()[0]);
72
72
  return extend(fields, {
73
73
  [fieldName]: pgField(build, fieldWithHooks, fieldName, {
74
- description: `An edge for our \`${tableTypeName}\`. May be used by Relay 1.`,
74
+ description: build.wrapDescription(`An edge for our \`${tableTypeName}\`. May be used by Relay 1.`, "field"),
75
75
  type: TableEdgeType,
76
76
  args: canOrderBy ? {
77
77
  orderBy: {
78
- description: `The method to use when ordering \`${tableTypeName}\`.`,
78
+ description: build.wrapDescription(`The method to use when ordering \`${tableTypeName}\`.`, "arg"),
79
79
  type: new GraphQLList(new GraphQLNonNull(TableOrderByType)),
80
80
  defaultValue: defaultValueEnum ? [defaultValueEnum.value] : null
81
81
  }
@@ -80,12 +80,18 @@ export default (function PgMutationPayloadEdgePlugin(
80
80
  fieldWithHooks,
81
81
  fieldName,
82
82
  {
83
- description: `An edge for our \`${tableTypeName}\`. May be used by Relay 1.`,
83
+ description: build.wrapDescription(
84
+ `An edge for our \`${tableTypeName}\`. May be used by Relay 1.`,
85
+ "field"
86
+ ),
84
87
  type: TableEdgeType,
85
88
  args: canOrderBy
86
89
  ? {
87
90
  orderBy: {
88
- description: `The method to use when ordering \`${tableTypeName}\`.`,
91
+ description: build.wrapDescription(
92
+ `The method to use when ordering \`${tableTypeName}\`.`,
93
+ "arg"
94
+ ),
89
95
  type: new GraphQLList(
90
96
  new GraphQLNonNull(TableOrderByType)
91
97
  ),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/PgMutationPayloadEdgePlugin.js"],"names":["PgMutationPayloadEdgePlugin","builder","pgSimpleCollections","disableIssue397Fix","hook","fields","build","context","extend","getSafeAliasFromResolveInfo","getTypeByName","pgGetGqlTypeByTypeIdAndModifier","pgSql","sql","graphql","GraphQLList","GraphQLNonNull","inflection","pgOmit","omit","describePgEntity","pgField","scope","isMutationPayload","pgIntrospection","pgIntrospectionTable","fieldWithHooks","Self","table","kind","namespace","isSelectable","returnTypeId","typeId","returnsSet","simpleCollections","tags","hasConnections","TableType","type","id","tableTypeName","name","TableOrderByType","orderByType","TableEdgeType","edge","primaryKeyConstraint","primaryKeys","keyAttributes","canOrderBy","fieldName","edgeField","defaultValueEnum","getValues","find","v","description","args","orderBy","defaultValue","value","resolve","data","rawOrderBy","_context","resolveInfo","safeAlias","Array","isArray","order","some","item","alias","filter","__identifiers","__cursor","map","join","isPgMutationPayloadEdgeField","pgFieldIntrospection","withQueryBuilder","queryBuilder","parsedResolveInfoFragment","aliases","expressions","unique","forEach","specs","itemIsUnique","orders","col","_ascending","expr","fragment","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String from \"lodash/isString\";\n\nexport default (function PgMutationPayloadEdgePlugin(\n builder,\n { pgSimpleCollections, disableIssue397Fix }\n) {\n builder.hook(\n \"GraphQLObjectType:fields\",\n (fields, build, context) => {\n const {\n extend,\n getSafeAliasFromResolveInfo,\n getTypeByName,\n pgGetGqlTypeByTypeIdAndModifier,\n pgSql: sql,\n graphql: { GraphQLList, GraphQLNonNull },\n inflection,\n pgOmit: omit,\n describePgEntity,\n pgField,\n } = build;\n const {\n scope: { isMutationPayload, pgIntrospection, pgIntrospectionTable },\n fieldWithHooks,\n Self,\n } = context;\n\n const table = pgIntrospectionTable || pgIntrospection;\n if (\n !isMutationPayload ||\n !table ||\n table.kind !== \"class\" ||\n !table.namespace ||\n !table.isSelectable ||\n (omit(table, \"all\") && omit(table, \"many\"))\n ) {\n return fields;\n }\n if (\n pgIntrospection.kind === \"procedure\" &&\n (pgIntrospection.returnTypeId !== table.typeId ||\n pgIntrospection.returnsSet)\n ) {\n return fields;\n }\n const simpleCollections =\n table.tags.simpleCollections || pgSimpleCollections;\n const hasConnections = simpleCollections !== \"only\";\n if (!hasConnections && !disableIssue397Fix) {\n return fields;\n }\n\n const TableType = pgGetGqlTypeByTypeIdAndModifier(table.type.id, null);\n const tableTypeName = TableType.name;\n const TableOrderByType = getTypeByName(\n inflection.orderByType(tableTypeName)\n );\n const TableEdgeType = getTypeByName(inflection.edge(tableTypeName));\n if (!TableEdgeType) {\n return fields;\n }\n\n const primaryKeyConstraint = table.primaryKeyConstraint;\n const primaryKeys =\n primaryKeyConstraint && primaryKeyConstraint.keyAttributes;\n const canOrderBy = !omit(table, \"order\");\n\n const fieldName = inflection.edgeField(table);\n const defaultValueEnum =\n canOrderBy &&\n (TableOrderByType.getValues().find(v => v.name === \"PRIMARY_KEY_ASC\") ||\n TableOrderByType.getValues()[0]);\n return extend(\n fields,\n {\n [fieldName]: pgField(\n build,\n fieldWithHooks,\n fieldName,\n {\n description: `An edge for our \\`${tableTypeName}\\`. May be used by Relay 1.`,\n type: TableEdgeType,\n args: canOrderBy\n ? {\n orderBy: {\n description: `The method to use when ordering \\`${tableTypeName}\\`.`,\n type: new GraphQLList(\n new GraphQLNonNull(TableOrderByType)\n ),\n defaultValue: defaultValueEnum\n ? [defaultValueEnum.value]\n : null,\n },\n }\n : {},\n resolve(data, { orderBy: rawOrderBy }, _context, resolveInfo) {\n if (!data.data) {\n return null;\n }\n const safeAlias = getSafeAliasFromResolveInfo(resolveInfo);\n const edge = data.data[safeAlias];\n if (!edge) {\n return null;\n }\n const orderBy =\n canOrderBy && rawOrderBy\n ? Array.isArray(rawOrderBy)\n ? rawOrderBy\n : [rawOrderBy]\n : null;\n const order =\n orderBy && orderBy.some(item => item.alias)\n ? orderBy.filter(item => item.alias)\n : null;\n\n if (!order) {\n if (edge.__identifiers) {\n return {\n ...edge,\n __cursor: [\"primary_key_asc\", edge.__identifiers],\n };\n } else {\n return edge;\n }\n }\n\n return {\n ...edge,\n __cursor:\n edge[`__order_${order.map(item => item.alias).join(\"__\")}`],\n };\n },\n },\n {\n isPgMutationPayloadEdgeField: true,\n pgFieldIntrospection: table,\n },\n false,\n {\n withQueryBuilder(queryBuilder, { parsedResolveInfoFragment }) {\n const {\n args: { orderBy: rawOrderBy },\n } = parsedResolveInfoFragment;\n const orderBy =\n canOrderBy && rawOrderBy\n ? Array.isArray(rawOrderBy)\n ? rawOrderBy\n : [rawOrderBy]\n : null;\n if (orderBy != null) {\n const aliases = [];\n const expressions = [];\n let unique = false;\n orderBy.forEach(item => {\n const { alias, specs, unique: itemIsUnique } = item;\n unique = unique || itemIsUnique;\n const orders = Array.isArray(specs[0]) ? specs : [specs];\n orders.forEach(([col, _ascending]) => {\n if (!col) {\n return;\n }\n const expr = isString(col)\n ? sql.fragment`${queryBuilder.getTableAlias()}.${sql.identifier(\n col\n )}`\n : col;\n expressions.push(expr);\n });\n if (alias == null) return;\n aliases.push(alias);\n });\n if (!unique && primaryKeys) {\n // Add PKs\n primaryKeys.forEach(key => {\n expressions.push(\n sql.fragment`${queryBuilder.getTableAlias()}.${sql.identifier(\n key.name\n )}`\n );\n });\n }\n if (aliases.length) {\n queryBuilder.select(\n sql.fragment`json_build_array(${sql.join(\n aliases.map(a => sql.fragment`${sql.literal(a)}::text`),\n \", \"\n )}, json_build_array(${sql.join(expressions, \", \")}))`,\n \"__order_\" + aliases.join(\"__\")\n );\n }\n }\n },\n }\n ),\n },\n `Adding edge field for table ${describePgEntity(\n table\n )} to mutation payload '${Self.name}'`\n );\n },\n [\"PgMutationPayloadEdge\"]\n );\n}: Plugin);\n"],"file":"PgMutationPayloadEdgePlugin.js"}
1
+ {"version":3,"sources":["../../src/plugins/PgMutationPayloadEdgePlugin.js"],"names":["PgMutationPayloadEdgePlugin","builder","pgSimpleCollections","disableIssue397Fix","hook","fields","build","context","extend","getSafeAliasFromResolveInfo","getTypeByName","pgGetGqlTypeByTypeIdAndModifier","pgSql","sql","graphql","GraphQLList","GraphQLNonNull","inflection","pgOmit","omit","describePgEntity","pgField","scope","isMutationPayload","pgIntrospection","pgIntrospectionTable","fieldWithHooks","Self","table","kind","namespace","isSelectable","returnTypeId","typeId","returnsSet","simpleCollections","tags","hasConnections","TableType","type","id","tableTypeName","name","TableOrderByType","orderByType","TableEdgeType","edge","primaryKeyConstraint","primaryKeys","keyAttributes","canOrderBy","fieldName","edgeField","defaultValueEnum","getValues","find","v","description","wrapDescription","args","orderBy","defaultValue","value","resolve","data","rawOrderBy","_context","resolveInfo","safeAlias","Array","isArray","order","some","item","alias","filter","__identifiers","__cursor","map","join","isPgMutationPayloadEdgeField","pgFieldIntrospection","withQueryBuilder","queryBuilder","parsedResolveInfoFragment","aliases","expressions","unique","forEach","specs","itemIsUnique","orders","col","_ascending","expr","fragment","getTableAlias","identifier","push","key","length","select","a","literal"],"mappings":";;;;;;;AAEA;;;;IAEyBA,2B,GAAT,SAASA,2BAAT,CACdC,OADc,EAEd;AAAEC,EAAAA,mBAAF;AAAuBC,EAAAA;AAAvB,CAFc,EAGd;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CAACoF,UAAJ,CAC7CL,GAD6C,CAE7C,EAHO,GAITA,GAJJ;AAKAN,gBAAAA,WAAW,CAACY,IAAZ,CAAiBJ,IAAjB;AACD,eAVD;AAWA,kBAAIpB,KAAK,IAAI,IAAb,EAAmB;AACnBW,cAAAA,OAAO,CAACa,IAAR,CAAaxB,KAAb;AACD,aAjBD;;AAkBA,gBAAI,CAACa,MAAD,IAAWvC,WAAf,EAA4B;AAC1B;AACAA,cAAAA,WAAW,CAACwC,OAAZ,CAAoBW,GAAG,IAAI;AACzBb,gBAAAA,WAAW,CAACY,IAAZ,CACErF,GAAG,CAACkF,QAAS,GAAEZ,YAAY,CAACa,aAAb,EAA6B,IAAGnF,GAAG,CAACoF,UAAJ,CAC7CE,GAAG,CAACzD,IADyC,CAE7C,EAHJ;AAKD,eAND;AAOD;;AACD,gBAAI2C,OAAO,CAACe,MAAZ,EAAoB;AAClBjB,cAAAA,YAAY,CAACkB,MAAb,CACExF,GAAG,CAACkF,QAAS,oBAAmBlF,GAAG,CAACkE,IAAJ,CAC9BM,OAAO,CAACP,GAAR,CAAYwB,CAAC,IAAIzF,GAAG,CAACkF,QAAS,GAAElF,GAAG,CAAC0F,OAAJ,CAAYD,CAAZ,CAAe,QAA/C,CAD8B,EAE9B,IAF8B,CAG9B,sBAAqBzF,GAAG,CAACkE,IAAJ,CAASO,WAAT,EAAsB,IAAtB,CAA4B,IAJrD,EAKE,aAAaD,OAAO,CAACN,IAAR,CAAa,IAAb,CALf;AAOD;AACF;AACF;;AArDH,OArEkB;AADtB,KAFW,EAiIV,+BAA8B3D,gBAAgB,CAC7CQ,KAD6C,CAE7C,yBAAwBD,IAAI,CAACe,IAAK,GAnIzB,CAAb;AAqID,GAvMH,EAwME,CAAC,uBAAD,CAxMF;AA0MD,C","sourcesContent":["// @flow\nimport type { Plugin } from \"graphile-build\";\nimport isString from \"lodash/isString\";\n\nexport default (function PgMutationPayloadEdgePlugin(\n builder,\n { pgSimpleCollections, disableIssue397Fix }\n) {\n builder.hook(\n \"GraphQLObjectType:fields\",\n (fields, build, context) => {\n const {\n extend,\n getSafeAliasFromResolveInfo,\n getTypeByName,\n pgGetGqlTypeByTypeIdAndModifier,\n pgSql: sql,\n graphql: { GraphQLList, GraphQLNonNull },\n inflection,\n pgOmit: omit,\n describePgEntity,\n pgField,\n } = build;\n const {\n scope: { isMutationPayload, pgIntrospection, pgIntrospectionTable },\n fieldWithHooks,\n Self,\n } = context;\n\n const table = pgIntrospectionTable || pgIntrospection;\n if (\n !isMutationPayload ||\n !table ||\n table.kind !== \"class\" ||\n !table.namespace ||\n !table.isSelectable ||\n (omit(table, \"all\") && omit(table, \"many\"))\n ) {\n return fields;\n }\n if (\n pgIntrospection.kind === \"procedure\" &&\n (pgIntrospection.returnTypeId !== table.typeId ||\n pgIntrospection.returnsSet)\n ) {\n return fields;\n }\n const simpleCollections =\n table.tags.simpleCollections || pgSimpleCollections;\n const hasConnections = simpleCollections !== \"only\";\n if (!hasConnections && !disableIssue397Fix) {\n return fields;\n }\n\n const TableType = pgGetGqlTypeByTypeIdAndModifier(table.type.id, null);\n const tableTypeName = TableType.name;\n const TableOrderByType = getTypeByName(\n inflection.orderByType(tableTypeName)\n );\n const TableEdgeType = getTypeByName(inflection.edge(tableTypeName));\n if (!TableEdgeType) {\n return fields;\n }\n\n const primaryKeyConstraint = table.primaryKeyConstraint;\n const primaryKeys =\n primaryKeyConstraint && primaryKeyConstraint.keyAttributes;\n const canOrderBy = !omit(table, \"order\");\n\n const fieldName = inflection.edgeField(table);\n const defaultValueEnum =\n canOrderBy &&\n (TableOrderByType.getValues().find(v => v.name === \"PRIMARY_KEY_ASC\") ||\n TableOrderByType.getValues()[0]);\n return extend(\n fields,\n {\n [fieldName]: pgField(\n build,\n fieldWithHooks,\n fieldName,\n {\n description: build.wrapDescription(\n `An edge for our \\`${tableTypeName}\\`. May be used by Relay 1.`,\n \"field\"\n ),\n type: TableEdgeType,\n args: canOrderBy\n ? {\n orderBy: {\n description: build.wrapDescription(\n `The method to use when ordering \\`${tableTypeName}\\`.`,\n \"arg\"\n ),\n type: new GraphQLList(\n new GraphQLNonNull(TableOrderByType)\n ),\n defaultValue: defaultValueEnum\n ? [defaultValueEnum.value]\n : null,\n },\n }\n : {},\n resolve(data, { orderBy: rawOrderBy }, _context, resolveInfo) {\n if (!data.data) {\n return null;\n }\n const safeAlias = getSafeAliasFromResolveInfo(resolveInfo);\n const edge = data.data[safeAlias];\n if (!edge) {\n return null;\n }\n const orderBy =\n canOrderBy && rawOrderBy\n ? Array.isArray(rawOrderBy)\n ? rawOrderBy\n : [rawOrderBy]\n : null;\n const order =\n orderBy && orderBy.some(item => item.alias)\n ? orderBy.filter(item => item.alias)\n : null;\n\n if (!order) {\n if (edge.__identifiers) {\n return {\n ...edge,\n __cursor: [\"primary_key_asc\", edge.__identifiers],\n };\n } else {\n return edge;\n }\n }\n\n return {\n ...edge,\n __cursor:\n edge[`__order_${order.map(item => item.alias).join(\"__\")}`],\n };\n },\n },\n {\n isPgMutationPayloadEdgeField: true,\n pgFieldIntrospection: table,\n },\n false,\n {\n withQueryBuilder(queryBuilder, { parsedResolveInfoFragment }) {\n const {\n args: { orderBy: rawOrderBy },\n } = parsedResolveInfoFragment;\n const orderBy =\n canOrderBy && rawOrderBy\n ? Array.isArray(rawOrderBy)\n ? rawOrderBy\n : [rawOrderBy]\n : null;\n if (orderBy != null) {\n const aliases = [];\n const expressions = [];\n let unique = false;\n orderBy.forEach(item => {\n const { alias, specs, unique: itemIsUnique } = item;\n unique = unique || itemIsUnique;\n const orders = Array.isArray(specs[0]) ? specs : [specs];\n orders.forEach(([col, _ascending]) => {\n if (!col) {\n return;\n }\n const expr = isString(col)\n ? sql.fragment`${queryBuilder.getTableAlias()}.${sql.identifier(\n col\n )}`\n : col;\n expressions.push(expr);\n });\n if (alias == null) return;\n aliases.push(alias);\n });\n if (!unique && primaryKeys) {\n // Add PKs\n primaryKeys.forEach(key => {\n expressions.push(\n sql.fragment`${queryBuilder.getTableAlias()}.${sql.identifier(\n key.name\n )}`\n );\n });\n }\n if (aliases.length) {\n queryBuilder.select(\n sql.fragment`json_build_array(${sql.join(\n aliases.map(a => sql.fragment`${sql.literal(a)}::text`),\n \", \"\n )}, json_build_array(${sql.join(expressions, \", \")}))`,\n \"__order_\" + aliases.join(\"__\")\n );\n }\n }\n },\n }\n ),\n },\n `Adding edge field for table ${describePgEntity(\n table\n )} to mutation payload '${Self.name}'`\n );\n },\n [\"PgMutationPayloadEdge\"]\n );\n}: Plugin);\n"],"file":"PgMutationPayloadEdgePlugin.js"}
@@ -149,7 +149,7 @@ returning *`;
149
149
  const TablePatch = getTypeByName(inflection.patchType(Table.name));
150
150
  const PayloadType = newWithHooks(GraphQLObjectType, {
151
151
  name: inflection[mode === "delete" ? "deletePayloadType" : "updatePayloadType"](table),
152
- description: `The output of our ${mode} \`${tableTypeName}\` mutation.`,
152
+ description: build.wrapDescription(`The output of our ${mode} \`${tableTypeName}\` mutation.`, "type"),
153
153
  fields: ({
154
154
  fieldWithHooks
155
155
  }) => {
@@ -158,11 +158,11 @@ returning *`;
158
158
  const deletedNodeIdFieldName = inflection.deletedNodeId(table);
159
159
  return Object.assign({
160
160
  clientMutationId: {
161
- description: "The exact same `clientMutationId` that was provided in the mutation input, unchanged and unused. May be used by a client to track mutations.",
161
+ description: build.wrapDescription("The exact same `clientMutationId` that was provided in the mutation input, unchanged and unused. May be used by a client to track mutations.", "field"),
162
162
  type: GraphQLString
163
163
  },
164
164
  [tableName]: pgField(build, fieldWithHooks, tableName, {
165
- description: `The \`${tableTypeName}\` that was ${mode}d by this mutation.`,
165
+ description: build.wrapDescription(`The \`${tableTypeName}\` that was ${mode}d by this mutation.`, "field"),
166
166
  type: Table
167
167
  }, {}, false)
168
168
  }, mode === "delete" ? {
@@ -205,20 +205,20 @@ returning *`;
205
205
  const primaryKeys = primaryKeyConstraint && primaryKeyConstraint.keyAttributes;
206
206
  const fieldName = inflection[mode === "update" ? "updateNode" : "deleteNode"](table);
207
207
  const InputType = newWithHooks(GraphQLInputObjectType, {
208
- description: `All input for the \`${fieldName}\` mutation.`,
208
+ description: build.wrapDescription(`All input for the \`${fieldName}\` mutation.`, "type"),
209
209
  name: inflection[mode === "update" ? "updateNodeInputType" : "deleteNodeInputType"](table),
210
210
  fields: Object.assign({
211
211
  clientMutationId: {
212
- description: "An arbitrary string value with no semantic meaning. Will be included in the payload verbatim. May be used to track mutations by the client.",
212
+ description: build.wrapDescription("An arbitrary string value with no semantic meaning. Will be included in the payload verbatim. May be used to track mutations by the client.", "field"),
213
213
  type: GraphQLString
214
214
  },
215
215
  [nodeIdFieldName]: {
216
- description: `The globally unique \`ID\` which will identify a single \`${tableTypeName}\` to be ${mode}d.`,
216
+ description: build.wrapDescription(`The globally unique \`ID\` which will identify a single \`${tableTypeName}\` to be ${mode}d.`, "field"),
217
217
  type: new GraphQLNonNull(GraphQLID)
218
218
  }
219
219
  }, mode === "update" ? {
220
220
  [inflection.patchField(inflection.tableFieldName(table))]: {
221
- description: `An object where the defined keys will be set on the \`${tableTypeName}\` being ${mode}d.`,
221
+ description: build.wrapDescription(`An object where the defined keys will be set on the \`${tableTypeName}\` being ${mode}d.`, "field"),
222
222
  type: new GraphQLNonNull(TablePatch)
223
223
  }
224
224
  } : null)
@@ -241,7 +241,7 @@ returning *`;
241
241
  getDataFromParsedResolveInfoFragment
242
242
  } = context;
243
243
  return {
244
- description: mode === "update" ? `Updates a single \`${tableTypeName}\` using its globally unique id and a patch.` : `Deletes a single \`${tableTypeName}\` using its globally unique id.`,
244
+ description: build.wrapDescription(mode === "update" ? `Updates a single \`${tableTypeName}\` using its globally unique id and a patch.` : `Deletes a single \`${tableTypeName}\` using its globally unique id.`, "field"),
245
245
  type: PayloadType,
246
246
  args: {
247
247
  input: {
@@ -306,7 +306,7 @@ returning *`;
306
306
 
307
307
  const fieldName = inflection[mode === "update" ? "updateByKeys" : "deleteByKeys"](keys, table, constraint);
308
308
  const InputType = newWithHooks(GraphQLInputObjectType, {
309
- description: `All input for the \`${fieldName}\` mutation.`,
309
+ description: build.wrapDescription(`All input for the \`${fieldName}\` mutation.`, "type"),
310
310
  name: inflection[mode === "update" ? "updateByKeysInputType" : "deleteByKeysInputType"](keys, table, constraint),
311
311
  fields: Object.assign({
312
312
  clientMutationId: {
@@ -314,7 +314,7 @@ returning *`;
314
314
  }
315
315
  }, mode === "update" ? {
316
316
  [inflection.patchField(inflection.tableFieldName(table))]: {
317
- description: `An object where the defined keys will be set on the \`${tableTypeName}\` being ${mode}d.`,
317
+ description: build.wrapDescription(`An object where the defined keys will be set on the \`${tableTypeName}\` being ${mode}d.`, "field"),
318
318
  type: new GraphQLNonNull(TablePatch)
319
319
  }
320
320
  } : null, keys.reduce((memo, key) => {
@@ -344,7 +344,7 @@ returning *`;
344
344
  getDataFromParsedResolveInfoFragment
345
345
  } = context;
346
346
  return {
347
- description: mode === "update" ? `Updates a single \`${tableTypeName}\` using a unique key and a patch.` : `Deletes a single \`${tableTypeName}\` using a unique key.`,
347
+ description: build.wrapDescription(mode === "update" ? `Updates a single \`${tableTypeName}\` using a unique key and a patch.` : `Deletes a single \`${tableTypeName}\` using a unique key.`, "field"),
348
348
  type: PayloadType,
349
349
  args: {
350
350
  input: {
@@ -204,7 +204,10 @@ returning *`;
204
204
  ? "deletePayloadType"
205
205
  : "updatePayloadType"
206
206
  ](table),
207
- description: `The output of our ${mode} \`${tableTypeName}\` mutation.`,
207
+ description: build.wrapDescription(
208
+ `The output of our ${mode} \`${tableTypeName}\` mutation.`,
209
+ "type"
210
+ ),
208
211
  fields: ({ fieldWithHooks }) => {
209
212
  const tableName = inflection.tableFieldName(table);
210
213
  // This should really be `-node-id` but for compatibility with PostGraphQL v3 we haven't made that change.
@@ -214,8 +217,10 @@ returning *`;
214
217
  return Object.assign(
215
218
  {
216
219
  clientMutationId: {
217
- description:
220
+ description: build.wrapDescription(
218
221
  "The exact same `clientMutationId` that was provided in the mutation input, unchanged and unused. May be used by a client to track mutations.",
222
+ "field"
223
+ ),
219
224
  type: GraphQLString,
220
225
  },
221
226
  [tableName]: pgField(
@@ -223,7 +228,10 @@ returning *`;
223
228
  fieldWithHooks,
224
229
  tableName,
225
230
  {
226
- description: `The \`${tableTypeName}\` that was ${mode}d by this mutation.`,
231
+ description: build.wrapDescription(
232
+ `The \`${tableTypeName}\` that was ${mode}d by this mutation.`,
233
+ "field"
234
+ ),
227
235
  type: Table,
228
236
  },
229
237
  {},
@@ -296,7 +304,10 @@ returning *`;
296
304
  const InputType = newWithHooks(
297
305
  GraphQLInputObjectType,
298
306
  {
299
- description: `All input for the \`${fieldName}\` mutation.`,
307
+ description: build.wrapDescription(
308
+ `All input for the \`${fieldName}\` mutation.`,
309
+ "type"
310
+ ),
300
311
  name: inflection[
301
312
  mode === "update"
302
313
  ? "updateNodeInputType"
@@ -305,12 +316,17 @@ returning *`;
305
316
  fields: Object.assign(
306
317
  {
307
318
  clientMutationId: {
308
- description:
319
+ description: build.wrapDescription(
309
320
  "An arbitrary string value with no semantic meaning. Will be included in the payload verbatim. May be used to track mutations by the client.",
321
+ "field"
322
+ ),
310
323
  type: GraphQLString,
311
324
  },
312
325
  [nodeIdFieldName]: {
313
- description: `The globally unique \`ID\` which will identify a single \`${tableTypeName}\` to be ${mode}d.`,
326
+ description: build.wrapDescription(
327
+ `The globally unique \`ID\` which will identify a single \`${tableTypeName}\` to be ${mode}d.`,
328
+ "field"
329
+ ),
314
330
  type: new GraphQLNonNull(GraphQLID),
315
331
  },
316
332
  },
@@ -319,7 +335,10 @@ returning *`;
319
335
  [inflection.patchField(
320
336
  inflection.tableFieldName(table)
321
337
  )]: {
322
- description: `An object where the defined keys will be set on the \`${tableTypeName}\` being ${mode}d.`,
338
+ description: build.wrapDescription(
339
+ `An object where the defined keys will be set on the \`${tableTypeName}\` being ${mode}d.`,
340
+ "field"
341
+ ),
323
342
  type: new GraphQLNonNull(TablePatch),
324
343
  },
325
344
  }
@@ -355,10 +374,12 @@ returning *`;
355
374
  getDataFromParsedResolveInfoFragment,
356
375
  } = context;
357
376
  return {
358
- description:
377
+ description: build.wrapDescription(
359
378
  mode === "update"
360
379
  ? `Updates a single \`${tableTypeName}\` using its globally unique id and a patch.`
361
380
  : `Deletes a single \`${tableTypeName}\` using its globally unique id.`,
381
+ "field"
382
+ ),
362
383
  type: PayloadType,
363
384
  args: {
364
385
  input: {
@@ -450,7 +471,10 @@ returning *`;
450
471
  const InputType = newWithHooks(
451
472
  GraphQLInputObjectType,
452
473
  {
453
- description: `All input for the \`${fieldName}\` mutation.`,
474
+ description: build.wrapDescription(
475
+ `All input for the \`${fieldName}\` mutation.`,
476
+ "type"
477
+ ),
454
478
  name: inflection[
455
479
  mode === "update"
456
480
  ? "updateByKeysInputType"
@@ -467,7 +491,10 @@ returning *`;
467
491
  [inflection.patchField(
468
492
  inflection.tableFieldName(table)
469
493
  )]: {
470
- description: `An object where the defined keys will be set on the \`${tableTypeName}\` being ${mode}d.`,
494
+ description: build.wrapDescription(
495
+ `An object where the defined keys will be set on the \`${tableTypeName}\` being ${mode}d.`,
496
+ "field"
497
+ ),
471
498
  type: new GraphQLNonNull(TablePatch),
472
499
  },
473
500
  }
@@ -516,10 +543,12 @@ returning *`;
516
543
  getDataFromParsedResolveInfoFragment,
517
544
  } = context;
518
545
  return {
519
- description:
546
+ description: build.wrapDescription(
520
547
  mode === "update"
521
548
  ? `Updates a single \`${tableTypeName}\` using a unique key and a patch.`
522
549
  : `Deletes a single \`${tableTypeName}\` using a unique key.`,
550
+ "field"
551
+ ),
523
552
  type: PayloadType,
524
553
  args: {
525
554
  input: {