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/PgRowNode.js"],"names":["PgRowNode","builder","subscriptions","hook","object","build","context","addNodeFetcherForTypeName","pgSql","sql","gql2pg","pgQueryFromResolveData","queryFromResolveData","pgOmit","omit","pgPrepareAndRun","scope","isPgRowType","pgIntrospection","table","namespace","sqlFullTableName","identifier","name","primaryKeyConstraint","primaryKeys","keyAttributes","data","identifiers","resolveContext","parsedResolveInfoFragment","ReturnType","resolveData","resolveInfo","pgClient","liveRecord","rootValue","length","Error","query","undefined","useAsterisk","queryBuilder","selectIdentifiers","forEach","key","idx","where","fragment","getTableAlias","type","typeModifier","text","values","compile","debugSql","enabled","rows","row","__identifiers","fields","nodeIdFieldName","getTypeAndIdentifiersFromNodeId","extend","parseResolveInfo","pgGetGqlTypeByTypeIdAndModifier","pgIntrospectionResultsByKind","introspectionResultsByKind","graphql","GraphQLNonNull","GraphQLID","inflection","describePgEntity","sqlCommentByAddingTags","isRootQuery","fieldWithHooks","class","reduce","memo","TableType","id","fieldName","tableNode","getDataFromParsedResolveInfoFragment","description","args","resolve","parent","nodeId","Type","e","isPgNodeQuery","pgFieldIntrospection"],"mappings":";;;;;;;AAEA;;;;IAE+BA,S,GAAf,eAAeA,SAAf,CAAyBC,OAAzB,EAAkC;AAAEC,EAAAA;AAAF,CAAlC,EAAqD;AACnED,EAAAA,OAAO,CAACE,IAAR,CACE,mBADF,EAEE,CAACC,MAAD,EAASC,KAAT,EAAgBC,OAAhB,KAA4B;AAC1B,UAAM;AACJC,MAAAA,yBADI;AAEJC,MAAAA,KAAK,EAAEC,GAFH;AAGJC,MAAAA,MAHI;AAIJC,MAAAA,sBAAsB,EAAEC,oBAJpB;AAKJC,MAAAA,MAAM,EAAEC,IALJ;AAMJC,MAAAA;AANI,QAOFV,KAPJ;AAQA,UAAM;AACJW,MAAAA,KAAK,EAAE;AAAEC,QAAAA,WAAF;AAAeC,QAAAA,eAAe,EAAEC;AAAhC;AADH,QAEFb,OAFJ;;AAIA,QAAI,CAACC,yBAAL,EAAgC;AAC9B;AACA,aAAOH,MAAP;AACD;;AACD,QAAI,CAACa,WAAD,IAAgB,CAACE,KAAK,CAACC,SAAvB,IAAoCN,IAAI,CAACK,KAAD,EAAQ,MAAR,CAA5C,EAA6D;AAC3D,aAAOf,MAAP;AACD;;AACD,UAAMiB,gBAAgB,GAAGZ,GAAG,CAACa,UAAJ,CAAeH,KAAK,CAACC,SAAN,CAAgBG,IAA/B,EAAqCJ,KAAK,CAACI,IAA3C,CAAzB;AACA,UAAMC,oBAAoB,GAAGL,KAAK,CAACK,oBAAnC;;AACA,QAAI,CAACA,oBAAL,EAA2B;AACzB,aAAOp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,GAxJH,EAyJE,CAAC,WAAD,CAzJF;AA2JD,C","sourcesContent":["// @flow\nimport type { Plugin } from \"graphile-build\";\nimport debugSql from \"./debugSql\";\n\nexport default (async function PgRowNode(builder, { subscriptions }) {\n builder.hook(\n \"GraphQLObjectType\",\n (object, build, context) => {\n const {\n addNodeFetcherForTypeName,\n pgSql: sql,\n gql2pg,\n pgQueryFromResolveData: queryFromResolveData,\n pgOmit: omit,\n pgPrepareAndRun,\n } = build;\n const {\n scope: { isPgRowType, pgIntrospection: table },\n } = context;\n\n if (!addNodeFetcherForTypeName) {\n // Node plugin must be disabled.\n return object;\n }\n if (!isPgRowType || !table.namespace || omit(table, \"read\")) {\n return object;\n }\n const sqlFullTableName = sql.identifier(table.namespace.name, table.name);\n const primaryKeyConstraint = table.primaryKeyConstraint;\n if (!primaryKeyConstraint) {\n return object;\n }\n const primaryKeys =\n primaryKeyConstraint && primaryKeyConstraint.keyAttributes;\n\n addNodeFetcherForTypeName(\n object.name,\n async (\n data,\n identifiers,\n resolveContext,\n parsedResolveInfoFragment,\n ReturnType,\n resolveData,\n resolveInfo\n ) => {\n const { pgClient } = resolveContext;\n const liveRecord =\n resolveInfo &&\n resolveInfo.rootValue &&\n resolveInfo.rootValue.liveRecord;\n if (identifiers.length !== primaryKeys.length) {\n throw new Error(\"Invalid ID\");\n }\n const query = queryFromResolveData(\n sqlFullTableName,\n undefined,\n resolveData,\n {\n useAsterisk: false, // Because it's only a single relation, no need\n },\n queryBuilder => {\n if (subscriptions && table.primaryKeyConstraint) {\n queryBuilder.selectIdentifiers(table);\n }\n primaryKeys.forEach((key, idx) => {\n queryBuilder.where(\n sql.fragment`${queryBuilder.getTableAlias()}.${sql.identifier(\n key.name\n )} = ${gql2pg(\n identifiers[idx],\n primaryKeys[idx].type,\n primaryKeys[idx].typeModifier\n )}`\n );\n });\n },\n resolveContext,\n resolveInfo && resolveInfo.rootValue\n );\n const { text, values } = sql.compile(query);\n if (debugSql.enabled) debugSql(text);\n const {\n rows: [row],\n } = await pgPrepareAndRun(pgClient, text, values);\n if (subscriptions && liveRecord && row) {\n liveRecord(\"pg\", table, row.__identifiers);\n }\n return row;\n }\n );\n return object;\n },\n [\"PgRowNode\"]\n );\n\n builder.hook(\n \"GraphQLObjectType:fields\",\n (fields, build, context) => {\n const {\n nodeIdFieldName,\n getTypeAndIdentifiersFromNodeId,\n extend,\n parseResolveInfo,\n pgGetGqlTypeByTypeIdAndModifier,\n pgIntrospectionResultsByKind: introspectionResultsByKind,\n pgSql: sql,\n gql2pg,\n graphql: { GraphQLNonNull, GraphQLID },\n inflection,\n pgQueryFromResolveData: queryFromResolveData,\n pgOmit: omit,\n describePgEntity,\n sqlCommentByAddingTags,\n pgPrepareAndRun,\n } = build;\n const {\n scope: { isRootQuery },\n fieldWithHooks,\n } = context;\n\n if (!isRootQuery || !nodeIdFieldName) {\n return fields;\n }\n\n return extend(\n fields,\n introspectionResultsByKind.class.reduce((memo, table) => {\n // PERFORMANCE: These used to be .filter(...) calls\n if (!table.namespace) return memo;\n if (omit(table, \"read\")) return memo;\n\n const TableType = pgGetGqlTypeByTypeIdAndModifier(\n table.type.id,\n null\n );\n const sqlFullTableName = sql.identifier(\n table.namespace.name,\n table.name\n );\n if (TableType) {\n const primaryKeyConstraint = table.primaryKeyConstraint;\n if (!primaryKeyConstraint) {\n return memo;\n }\n const primaryKeys =\n primaryKeyConstraint && primaryKeyConstraint.keyAttributes;\n const fieldName = inflection.tableNode(table);\n memo = extend(\n memo,\n {\n [fieldName]: fieldWithHooks(\n fieldName,\n ({ getDataFromParsedResolveInfoFragment }) => {\n return {\n description: `Reads a single \\`${TableType.name}\\` using its globally unique \\`ID\\`.`,\n type: TableType,\n args: {\n [nodeIdFieldName]: {\n description: `The globally unique \\`ID\\` to be used in selecting a single \\`${TableType.name}\\`.`,\n type: new GraphQLNonNull(GraphQLID),\n },\n },\n async resolve(parent, args, resolveContext, resolveInfo) {\n const { pgClient } = resolveContext;\n const liveRecord =\n resolveInfo.rootValue &&\n resolveInfo.rootValue.liveRecord;\n const nodeId = args[nodeIdFieldName];\n try {\n const {\n Type,\n identifiers,\n } = getTypeAndIdentifiersFromNodeId(nodeId);\n if (Type !== TableType) {\n throw new Error(\"Mismatched type\");\n }\n if (identifiers.length !== primaryKeys.length) {\n throw new Error(\"Invalid ID\");\n }\n\n const parsedResolveInfoFragment = parseResolveInfo(\n resolveInfo\n );\n parsedResolveInfoFragment.args = args; // Allow overriding via makeWrapResolversPlugin\n const resolveData = getDataFromParsedResolveInfoFragment(\n parsedResolveInfoFragment,\n TableType\n );\n const query = queryFromResolveData(\n sqlFullTableName,\n undefined,\n resolveData,\n {\n useAsterisk: false, // Because it's only a single relation, no need\n },\n queryBuilder => {\n if (subscriptions && table.primaryKeyConstraint) {\n queryBuilder.selectIdentifiers(table);\n }\n primaryKeys.forEach((key, idx) => {\n queryBuilder.where(\n sql.fragment`${queryBuilder.getTableAlias()}.${sql.identifier(\n key.name\n )} = ${gql2pg(\n identifiers[idx],\n primaryKeys[idx].type,\n primaryKeys[idx].typeModifier\n )}`\n );\n });\n },\n resolveContext,\n resolveInfo.rootValue\n );\n const { text, values } = sql.compile(query);\n if (debugSql.enabled) debugSql(text);\n const {\n rows: [row],\n } = await pgPrepareAndRun(pgClient, text, values);\n if (liveRecord && row) {\n liveRecord(\"pg\", table, row.__identifiers);\n }\n return row;\n } catch (e) {\n return null;\n }\n },\n };\n },\n {\n isPgNodeQuery: true,\n pgFieldIntrospection: table,\n }\n ),\n },\n `Adding row by globally unique identifier field for ${describePgEntity(\n table\n )}. You can rename this table via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n table,\n { name: \"newNameHere\" }\n )}`\n );\n }\n return memo;\n }, {}),\n `Adding \"row by node ID\" fields to root Query type`\n );\n },\n [\"PgRowNode\"]\n );\n}: Plugin);\n"],"file":"PgRowNode.js"}
1
+ {"version":3,"sources":["../../src/plugins/PgRowNode.js"],"names":["PgRowNode","builder","subscriptions","hook","object","build","context","addNodeFetcherForTypeName","pgSql","sql","gql2pg","pgQueryFromResolveData","queryFromResolveData","pgOmit","omit","pgPrepareAndRun","scope","isPgRowType","pgIntrospection","table","namespace","sqlFullTableName","identifier","name","primaryKeyConstraint","primaryKeys","keyAttributes","data","identifiers","resolveContext","parsedResolveInfoFragment","ReturnType","resolveData","resolveInfo","pgClient","liveRecord","rootValue","length","Error","query","undefined","useAsterisk","queryBuilder","selectIdentifiers","forEach","key","idx","where","fragment","getTableAlias","type","typeModifier","text","values","compile","debugSql","enabled","rows","row","__identifiers","fields","nodeIdFieldName","getTypeAndIdentifiersFromNodeId","extend","parseResolveInfo","pgGetGqlTypeByTypeIdAndModifier","pgIntrospectionResultsByKind","introspectionResultsByKind","graphql","GraphQLNonNull","GraphQLID","inflection","describePgEntity","sqlCommentByAddingTags","isRootQuery","fieldWithHooks","class","reduce","memo","TableType","id","fieldName","tableNode","getDataFromParsedResolveInfoFragment","description","wrapDescription","args","resolve","parent","nodeId","Type","e","isPgNodeQuery","pgFieldIntrospection"],"mappings":";;;;;;;AAEA;;;;IAE+BA,S,GAAf,eAAeA,SAAf,CAAyBC,OAAzB,EAAkC;AAAEC,EAAAA;AAAF,CAAlC,EAAqD;AACnED,EAAAA,OAAO,CAACE,IAAR,CACE,mBADF,EAEE,CAACC,MAAD,EAASC,KAAT,EAAgBC,OAAhB,KAA4B;AAC1B,UAAM;AACJC,MAAAA,yBADI;AAEJC,MAAAA,KAAK,EAAEC,GAFH;AAGJC,MAAAA,MAHI;AAIJC,MAAAA,sBAAsB,EAAEC,oBAJpB;AAKJC,MAAAA,MAAM,EAAEC,IALJ;AAMJC,MAAAA;AANI,QAOFV,KAPJ;AAQA,UAAM;AACJW,MAAAA,KAAK,EAAE;AAAEC,QAAAA,WAAF;AAAeC,QAAAA,eAAe,EAAEC;AAAhC;AADH,QAEFb,OAFJ;;AAIA,QAAI,CAACC,yBAAL,EAAgC;AAC9B;AACA,aAAOH,MAAP;AACD;;AACD,QAAI,CAACa,WAAD,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OAAOiC,CAAP,EAAU;AACV,yBAAO,IAAP;AACD;AACF;;AA/EI,aAAP;AAiFD,WApFwB,EAqFzB;AACEC,YAAAA,aAAa,EAAE,IADjB;AAEEC,YAAAA,oBAAoB,EAAE1E;AAFxB,WArFyB;AAD7B,SAFW,EA8FV,sDAAqDqD,gBAAgB,CACpErD,KADoE,CAEpE,2DAA0DsD,sBAAsB,CAChFtD,KADgF,EAEhF;AAAEI,UAAAA,IAAI,EAAE;AAAR,SAFgF,CAGhF,EAnGS,CAAb;AAqGD;;AACD,aAAOuD,IAAP;AACD,KA5HD,EA4HG,EA5HH,CAFW,EA+HV,mDA/HU,CAAb;AAiID,GA9JH,EA+JE,CAAC,WAAD,CA/JF;AAiKD,C","sourcesContent":["// @flow\nimport type { Plugin } from \"graphile-build\";\nimport debugSql from \"./debugSql\";\n\nexport default (async function PgRowNode(builder, { subscriptions }) {\n builder.hook(\n \"GraphQLObjectType\",\n (object, build, context) => {\n const {\n addNodeFetcherForTypeName,\n pgSql: sql,\n gql2pg,\n pgQueryFromResolveData: queryFromResolveData,\n pgOmit: omit,\n pgPrepareAndRun,\n } = build;\n const {\n scope: { isPgRowType, pgIntrospection: table },\n } = context;\n\n if (!addNodeFetcherForTypeName) {\n // Node plugin must be disabled.\n return object;\n }\n if (!isPgRowType || !table.namespace || omit(table, \"read\")) {\n return object;\n }\n const sqlFullTableName = sql.identifier(table.namespace.name, table.name);\n const primaryKeyConstraint = table.primaryKeyConstraint;\n if (!primaryKeyConstraint) {\n return object;\n }\n const primaryKeys =\n primaryKeyConstraint && primaryKeyConstraint.keyAttributes;\n\n addNodeFetcherForTypeName(\n object.name,\n async (\n data,\n identifiers,\n resolveContext,\n parsedResolveInfoFragment,\n ReturnType,\n resolveData,\n resolveInfo\n ) => {\n const { pgClient } = resolveContext;\n const liveRecord =\n resolveInfo &&\n resolveInfo.rootValue &&\n resolveInfo.rootValue.liveRecord;\n if (identifiers.length !== primaryKeys.length) {\n throw new Error(\"Invalid ID\");\n }\n const query = queryFromResolveData(\n sqlFullTableName,\n undefined,\n resolveData,\n {\n useAsterisk: false, // Because it's only a single relation, no need\n },\n queryBuilder => {\n if (subscriptions && table.primaryKeyConstraint) {\n queryBuilder.selectIdentifiers(table);\n }\n primaryKeys.forEach((key, idx) => {\n queryBuilder.where(\n sql.fragment`${queryBuilder.getTableAlias()}.${sql.identifier(\n key.name\n )} = ${gql2pg(\n identifiers[idx],\n primaryKeys[idx].type,\n primaryKeys[idx].typeModifier\n )}`\n );\n });\n },\n resolveContext,\n resolveInfo && resolveInfo.rootValue\n );\n const { text, values } = sql.compile(query);\n if (debugSql.enabled) debugSql(text);\n const {\n rows: [row],\n } = await pgPrepareAndRun(pgClient, text, values);\n if (subscriptions && liveRecord && row) {\n liveRecord(\"pg\", table, row.__identifiers);\n }\n return row;\n }\n );\n return object;\n },\n [\"PgRowNode\"]\n );\n\n builder.hook(\n \"GraphQLObjectType:fields\",\n (fields, build, context) => {\n const {\n nodeIdFieldName,\n getTypeAndIdentifiersFromNodeId,\n extend,\n parseResolveInfo,\n pgGetGqlTypeByTypeIdAndModifier,\n pgIntrospectionResultsByKind: introspectionResultsByKind,\n pgSql: sql,\n gql2pg,\n graphql: { GraphQLNonNull, GraphQLID },\n inflection,\n pgQueryFromResolveData: queryFromResolveData,\n pgOmit: omit,\n describePgEntity,\n sqlCommentByAddingTags,\n pgPrepareAndRun,\n } = build;\n const {\n scope: { isRootQuery },\n fieldWithHooks,\n } = context;\n\n if (!isRootQuery || !nodeIdFieldName) {\n return fields;\n }\n\n return extend(\n fields,\n introspectionResultsByKind.class.reduce((memo, table) => {\n // PERFORMANCE: These used to be .filter(...) calls\n if (!table.namespace) return memo;\n if (omit(table, \"read\")) return memo;\n\n const TableType = pgGetGqlTypeByTypeIdAndModifier(\n table.type.id,\n null\n );\n const sqlFullTableName = sql.identifier(\n table.namespace.name,\n table.name\n );\n if (TableType) {\n const primaryKeyConstraint = table.primaryKeyConstraint;\n if (!primaryKeyConstraint) {\n return memo;\n }\n const primaryKeys =\n primaryKeyConstraint && primaryKeyConstraint.keyAttributes;\n const fieldName = inflection.tableNode(table);\n memo = extend(\n memo,\n {\n [fieldName]: fieldWithHooks(\n fieldName,\n ({ getDataFromParsedResolveInfoFragment }) => {\n return {\n description: build.wrapDescription(\n `Reads a single \\`${TableType.name}\\` using its globally unique \\`ID\\`.`,\n \"field\"\n ),\n type: TableType,\n args: {\n [nodeIdFieldName]: {\n description: build.wrapDescription(\n `The globally unique \\`ID\\` to be used in selecting a single \\`${TableType.name}\\`.`,\n \"arg\"\n ),\n type: new GraphQLNonNull(GraphQLID),\n },\n },\n async resolve(parent, args, resolveContext, resolveInfo) {\n const { pgClient } = resolveContext;\n const liveRecord =\n resolveInfo.rootValue &&\n resolveInfo.rootValue.liveRecord;\n const nodeId = args[nodeIdFieldName];\n try {\n const {\n Type,\n identifiers,\n } = getTypeAndIdentifiersFromNodeId(nodeId);\n if (Type !== TableType) {\n throw new Error(\"Mismatched type\");\n }\n if (identifiers.length !== primaryKeys.length) {\n throw new Error(\"Invalid ID\");\n }\n\n const parsedResolveInfoFragment = parseResolveInfo(\n resolveInfo\n );\n parsedResolveInfoFragment.args = args; // Allow overriding via makeWrapResolversPlugin\n const resolveData = getDataFromParsedResolveInfoFragment(\n parsedResolveInfoFragment,\n TableType\n );\n const query = queryFromResolveData(\n sqlFullTableName,\n undefined,\n resolveData,\n {\n useAsterisk: false, // Because it's only a single relation, no need\n },\n queryBuilder => {\n if (subscriptions && table.primaryKeyConstraint) {\n queryBuilder.selectIdentifiers(table);\n }\n primaryKeys.forEach((key, idx) => {\n queryBuilder.where(\n sql.fragment`${queryBuilder.getTableAlias()}.${sql.identifier(\n key.name\n )} = ${gql2pg(\n identifiers[idx],\n primaryKeys[idx].type,\n primaryKeys[idx].typeModifier\n )}`\n );\n });\n },\n resolveContext,\n resolveInfo.rootValue\n );\n const { text, values } = sql.compile(query);\n if (debugSql.enabled) debugSql(text);\n const {\n rows: [row],\n } = await pgPrepareAndRun(pgClient, text, values);\n if (liveRecord && row) {\n liveRecord(\"pg\", table, row.__identifiers);\n }\n return row;\n } catch (e) {\n return null;\n }\n },\n };\n },\n {\n isPgNodeQuery: true,\n pgFieldIntrospection: table,\n }\n ),\n },\n `Adding row by globally unique identifier field for ${describePgEntity(\n table\n )}. You can rename this table via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n table,\n { name: \"newNameHere\" }\n )}`\n );\n }\n return memo;\n }, {}),\n `Adding \"row by node ID\" fields to root Query type`\n );\n },\n [\"PgRowNode\"]\n );\n}: Plugin);\n"],"file":"PgRowNode.js"}
@@ -51,7 +51,7 @@ var PgScalarFunctionConnectionPlugin = function PgScalarFunctionConnectionPlugin
51
51
  const NodeType = pgGetGqlTypeByTypeIdAndModifier(returnType.id, null) || GraphQLString;
52
52
  const EdgeType = newWithHooks(GraphQLObjectType, {
53
53
  name: inflection.scalarFunctionEdge(proc),
54
- description: `A \`${NodeType.name}\` edge in the connection.`,
54
+ description: build.wrapDescription(`A \`${NodeType.name}\` edge in the connection.`, "type"),
55
55
  fields: ({
56
56
  fieldWithHooks
57
57
  }) => {
@@ -63,7 +63,7 @@ var PgScalarFunctionConnectionPlugin = function PgScalarFunctionConnectionPlugin
63
63
  usesCursor: [true]
64
64
  }));
65
65
  return {
66
- description: "A cursor for use in pagination.",
66
+ description: build.wrapDescription("A cursor for use in pagination.", "field"),
67
67
  type: Cursor,
68
68
 
69
69
  resolve(data) {
@@ -75,7 +75,7 @@ var PgScalarFunctionConnectionPlugin = function PgScalarFunctionConnectionPlugin
75
75
  isCursorField: true
76
76
  }),
77
77
  node: {
78
- description: `The \`${NodeType.name}\` at the end of the edge.`,
78
+ description: build.wrapDescription(`The \`${NodeType.name}\` at the end of the edge.`, "field"),
79
79
  type: NodeType,
80
80
 
81
81
  resolve(data) {
@@ -97,13 +97,13 @@ var PgScalarFunctionConnectionPlugin = function PgScalarFunctionConnectionPlugin
97
97
 
98
98
  newWithHooks(GraphQLObjectType, {
99
99
  name: inflection.scalarFunctionConnection(proc),
100
- description: `A connection to a list of \`${NodeType.name}\` values.`,
100
+ description: build.wrapDescription(`A connection to a list of \`${NodeType.name}\` values.`, "type"),
101
101
  fields: ({
102
102
  fieldWithHooks
103
103
  }) => {
104
104
  return {
105
105
  nodes: pgField(build, fieldWithHooks, "nodes", {
106
- description: `A list of \`${NodeType.name}\` objects.`,
106
+ description: build.wrapDescription(`A list of \`${NodeType.name}\` objects.`, "field"),
107
107
  type: new GraphQLNonNull(new GraphQLList(NodeType)),
108
108
 
109
109
  resolve(data) {
@@ -112,7 +112,7 @@ var PgScalarFunctionConnectionPlugin = function PgScalarFunctionConnectionPlugin
112
112
 
113
113
  }),
114
114
  edges: pgField(build, fieldWithHooks, "edges", {
115
- description: `A list of edges which contains the \`${NodeType.name}\` and cursor to aid in pagination.`,
115
+ description: build.wrapDescription(`A list of edges which contains the \`${NodeType.name}\` and cursor to aid in pagination.`, "field"),
116
116
  type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(EdgeType))),
117
117
 
118
118
  resolve(data) {
@@ -53,7 +53,10 @@ export default (function PgScalarFunctionConnectionPlugin(builder) {
53
53
  GraphQLObjectType,
54
54
  {
55
55
  name: inflection.scalarFunctionEdge(proc),
56
- description: `A \`${NodeType.name}\` edge in the connection.`,
56
+ description: build.wrapDescription(
57
+ `A \`${NodeType.name}\` edge in the connection.`,
58
+ "type"
59
+ ),
57
60
  fields: ({ fieldWithHooks }) => {
58
61
  return {
59
62
  cursor: fieldWithHooks(
@@ -63,7 +66,10 @@ export default (function PgScalarFunctionConnectionPlugin(builder) {
63
66
  usesCursor: [true],
64
67
  }));
65
68
  return {
66
- description: "A cursor for use in pagination.",
69
+ description: build.wrapDescription(
70
+ "A cursor for use in pagination.",
71
+ "field"
72
+ ),
67
73
  type: Cursor,
68
74
  resolve(data) {
69
75
  return base64(JSON.stringify(data.__cursor));
@@ -75,7 +81,10 @@ export default (function PgScalarFunctionConnectionPlugin(builder) {
75
81
  }
76
82
  ),
77
83
  node: {
78
- description: `The \`${NodeType.name}\` at the end of the edge.`,
84
+ description: build.wrapDescription(
85
+ `The \`${NodeType.name}\` at the end of the edge.`,
86
+ "field"
87
+ ),
79
88
  type: NodeType,
80
89
  resolve(data) {
81
90
  return data.value;
@@ -104,11 +113,17 @@ export default (function PgScalarFunctionConnectionPlugin(builder) {
104
113
  GraphQLObjectType,
105
114
  {
106
115
  name: inflection.scalarFunctionConnection(proc),
107
- description: `A connection to a list of \`${NodeType.name}\` values.`,
116
+ description: build.wrapDescription(
117
+ `A connection to a list of \`${NodeType.name}\` values.`,
118
+ "type"
119
+ ),
108
120
  fields: ({ fieldWithHooks }) => {
109
121
  return {
110
122
  nodes: pgField(build, fieldWithHooks, "nodes", {
111
- description: `A list of \`${NodeType.name}\` objects.`,
123
+ description: build.wrapDescription(
124
+ `A list of \`${NodeType.name}\` objects.`,
125
+ "field"
126
+ ),
112
127
  type: new GraphQLNonNull(new GraphQLList(NodeType)),
113
128
  resolve(data) {
114
129
  return data.data.map(entry => entry.value);
@@ -119,7 +134,10 @@ export default (function PgScalarFunctionConnectionPlugin(builder) {
119
134
  fieldWithHooks,
120
135
  "edges",
121
136
  {
122
- description: `A list of edges which contains the \`${NodeType.name}\` and cursor to aid in pagination.`,
137
+ description: build.wrapDescription(
138
+ `A list of edges which contains the \`${NodeType.name}\` and cursor to aid in pagination.`,
139
+ "field"
140
+ ),
123
141
  type: new GraphQLNonNull(
124
142
  new GraphQLList(new GraphQLNonNull(EdgeType))
125
143
  ),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/PgScalarFunctionConnectionPlugin.js"],"names":["base64","str","Buffer","from","String","toString","PgScalarFunctionConnectionPlugin","builder","hook","_","build","newWithHooks","pgIntrospectionResultsByKind","introspectionResultsByKind","getTypeByName","pgGetGqlTypeByTypeIdAndModifier","graphql","GraphQLObjectType","GraphQLNonNull","GraphQLList","GraphQLString","inflection","pgOmit","omit","describePgEntity","sqlCommentByAddingTags","pgField","Cursor","procedure","forEach","proc","returnsSet","namespace","returnType","typeById","returnTypeId","returnTypeTable","classById","classId","id","NodeType","EdgeType","name","scalarFunctionEdge","description","fields","fieldWithHooks","cursor","addDataGenerator","usesCursor","type","resolve","data","JSON","stringify","__cursor","isCursorField","node","value","__origin","isEdgeType","nodeType","pgIntrospection","scalarFunctionConnection","nodes","map","entry","edges","hoistCursor","isConnectionType","isPgRowConnectionType","edgeType"],"mappings":";;;;;;;AAGA,MAAMA,MAAM,GAAGC,GAAG,IAAIC,MAAM,CAACC,IAAP,CAAYC,MAAM,CAACH,GAAD,CAAlB,EAAyBI,QAAzB,CAAkC,QAAlC,CAAtB;;IAEyBC,gC,GAAT,SAASA,gCAAT,CAA0CC,OAA1C,EAAmD;AACjEA,EAAAA,OAAO,CAACC,IAAR,CACE,MADF,EAEE,CAACC,CAAD,EAAIC,KAAJ,KAAc;AACZ,UAAM;AACJC,MAAAA,YADI;AAEJC,MAAAA,4BAA4B,EAAEC,0BAF1B;AAGJC,MAAAA,aAHI;AAIJC,MAAAA,+BAJI;AAKJC,MAAAA,OAAO,EAAE;AACPC,QAAAA,iBADO;AAEPC,QAAAA,cAFO;AAGPC,QAAAA,WAHO;AAIPC,QAAAA;AAJO,OALL;AAWJC,MAAAA,UAXI;AAYJC,MAAAA,MAAM,EAAEC,IAZJ;AAaJC,MAAAA,gBAbI;AAcJC,MAAAA,sBAdI;AAeJC,MAAAA;AAfI,QAgBFhB,KAhBJ;AAkBA,UAAMiB,MAAM,GAAGb,aAAa,CAAC,QAAD,CAA5B;AACAD,IAAAA,0BAA0B,CAACe,SAA3B,CAAqCC,OAArC,CAA6CC,IAAI,IAAI;AACnD;AACA,UAAI,CAACA,IAAI,CAACC,UAAV,EAAsB;AACtB,UAAI,CAACD,IAAI,CAACE,SAAV,EAAqB;AACrB,UAAIT,IAAI,CAACO,IAAD,EAAO,SAAP,CAAR,EAA2B;AAE3B,YAAMG,UAAU,GACdpB,0BAA0B,CAAC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cAAAA,IAAI,EAAE,IAAIhC,cAAJ,CACJ,IAAIC,WAAJ,CAAgB,IAAID,cAAJ,CAAmBuB,QAAnB,CAAhB,CADI,CAFR;;AAKEU,cAAAA,OAAO,CAACC,IAAD,EAAO;AACZ,uBAAOA,IAAI,CAACA,IAAZ;AACD;;AAPH,aAJY,EAaZ,EAbY,EAcZ,KAdY,EAeZ;AACEgB,cAAAA,WAAW,EAAE;AADf,aAfY;AART,WAAP;AA4BD;AAhCH,OAFU,EAoCV;AACET,QAAAA,QAAQ,EAAG,uCAAsCnC,gBAAgB,CAC/DM,IAD+D,CAE/D,uGAAsGL,sBAAsB,CAC5HK,IAD4H,EAE5H;AACEY,UAAAA,IAAI,EAAE;AADR,SAF4H,CAK5H,EARJ;AASE2B,QAAAA,gBAAgB,EAAE,IATpB;AAUEC,QAAAA,qBAAqB,EAAE,IAVzB;AAWEC,QAAAA,QAAQ,EAAE9B,QAXZ;AAYEoB,QAAAA,QAAQ,EAAErB,QAZZ;AAaEsB,QAAAA,eAAe,EAAEhC;AAbnB,OApCU,CAAZ;AAoDD,KA9HD;AA+HA,WAAOrB,CAAP;AACD,GAtJH,EAuJE,CAAC,4BAAD,CAvJF,EAwJE,EAxJF,EAyJE,CAAC,SAAD,CAzJF;AA2JD,C","sourcesContent":["// @flow\nimport type { Plugin } from \"graphile-build\";\n\nconst base64 = str => Buffer.from(String(str)).toString(\"base64\");\n\nexport default (function PgScalarFunctionConnectionPlugin(builder) {\n builder.hook(\n \"init\",\n (_, build) => {\n const {\n newWithHooks,\n pgIntrospectionResultsByKind: introspectionResultsByKind,\n getTypeByName,\n pgGetGqlTypeByTypeIdAndModifier,\n graphql: {\n GraphQLObjectType,\n GraphQLNonNull,\n GraphQLList,\n GraphQLString,\n },\n inflection,\n pgOmit: omit,\n describePgEntity,\n sqlCommentByAddingTags,\n pgField,\n } = build;\n\n const Cursor = getTypeByName(\"Cursor\");\n introspectionResultsByKind.procedure.forEach(proc => {\n // PERFORMANCE: These used to be .filter(...) calls\n if (!proc.returnsSet) return;\n if (!proc.namespace) return;\n if (omit(proc, \"execute\")) return;\n\n const returnType =\n introspectionResultsByKind.typeById[proc.returnTypeId];\n const returnTypeTable =\n introspectionResultsByKind.classById[returnType.classId];\n if (returnTypeTable) {\n // Just use the standard table connection from PgTablesPlugin\n return;\n }\n if (returnType.id === \"2249\") {\n // Defer handling to PgRecordFunctionConnectionPlugin\n return;\n }\n // TODO: PG10 doesn't support the equivalent of pg_attribute.atttypemod\n // on function arguments and return types, however maybe a later\n // version of PG will?\n const NodeType =\n pgGetGqlTypeByTypeIdAndModifier(returnType.id, null) || GraphQLString;\n const EdgeType = newWithHooks(\n GraphQLObjectType,\n {\n name: inflection.scalarFunctionEdge(proc),\n description: `A \\`${NodeType.name}\\` edge in the connection.`,\n fields: ({ fieldWithHooks }) => {\n return {\n cursor: fieldWithHooks(\n \"cursor\",\n ({ addDataGenerator }) => {\n addDataGenerator(() => ({\n usesCursor: [true],\n }));\n return {\n description: \"A cursor for use in pagination.\",\n type: Cursor,\n resolve(data) {\n return base64(JSON.stringify(data.__cursor));\n },\n };\n },\n {\n isCursorField: true,\n }\n ),\n node: {\n description: `The \\`${NodeType.name}\\` at the end of the edge.`,\n type: NodeType,\n resolve(data) {\n return data.value;\n },\n },\n };\n },\n },\n {\n __origin: `Adding function result edge type for ${describePgEntity(\n proc\n )}. You can rename the function's GraphQL field (and its dependent types) via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n proc,\n {\n name: \"newNameHere\",\n }\n )}`,\n isEdgeType: true,\n nodeType: NodeType,\n pgIntrospection: proc,\n }\n );\n\n /*const ConnectionType = */\n newWithHooks(\n GraphQLObjectType,\n {\n name: inflection.scalarFunctionConnection(proc),\n description: `A connection to a list of \\`${NodeType.name}\\` values.`,\n fields: ({ fieldWithHooks }) => {\n return {\n nodes: pgField(build, fieldWithHooks, \"nodes\", {\n description: `A list of \\`${NodeType.name}\\` objects.`,\n type: new GraphQLNonNull(new GraphQLList(NodeType)),\n resolve(data) {\n return data.data.map(entry => entry.value);\n },\n }),\n edges: pgField(\n build,\n fieldWithHooks,\n \"edges\",\n {\n description: `A list of edges which contains the \\`${NodeType.name}\\` and cursor to aid in pagination.`,\n type: new GraphQLNonNull(\n new GraphQLList(new GraphQLNonNull(EdgeType))\n ),\n resolve(data) {\n return data.data;\n },\n },\n {},\n false,\n {\n hoistCursor: true,\n }\n ),\n };\n },\n },\n {\n __origin: `Adding function connection type for ${describePgEntity(\n proc\n )}. You can rename the function's GraphQL field (and its dependent types) via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n proc,\n {\n name: \"newNameHere\",\n }\n )}`,\n isConnectionType: true,\n isPgRowConnectionType: true,\n edgeType: EdgeType,\n nodeType: NodeType,\n pgIntrospection: proc,\n }\n );\n });\n return _;\n },\n [\"PgScalarFunctionConnection\"],\n [],\n [\"PgTypes\"]\n );\n}: Plugin);\n"],"file":"PgScalarFunctionConnectionPlugin.js"}
1
+ {"version":3,"sources":["../../src/plugins/PgScalarFunctionConnectionPlugin.js"],"names":["base64","str","Buffer","from","String","toString","PgScalarFunctionConnectionPlugin","builder","hook","_","build","newWithHooks","pgIntrospectionResultsByKind","introspectionResultsByKind","getTypeByName","pgGetGqlTypeByTypeIdAndModifier","graphql","GraphQLObjectType","GraphQLNonNull","GraphQLList","GraphQLString","inflection","pgOmit","omit","describePgEntity","sqlCommentByAddingTags","pgField","Cursor","procedure","forEach","proc","returnsSet","namespace","returnType","typeById","returnTypeId","returnTypeTable","classById","classId","id","NodeType","EdgeType","name","scalarFunctionEdge","description","wrapDescription","fields","fieldWithHooks","cursor","addDataGenerator","usesCursor","type","resolve","data","JSON","stringify","__cursor","isCursorField","node","value","__origin","isEdgeType","nodeType","pgIntrospection","scalarFunctionConnection","nodes","map","entry","edges","hoistCursor","isConnectionType","isPgRowConnectionType","edgeType"],"mappings":";;;;;;;AAGA,MAAMA,MAAM,GAAGC,GAAG,IAAIC,MAAM,CAACC,IAAP,CAA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W,cAAAA,OAAO,CAACC,IAAD,EAAO;AACZ,uBAAOA,IAAI,CAACA,IAAZ;AACD;;AAVH,aAJY,EAgBZ,EAhBY,EAiBZ,KAjBY,EAkBZ;AACEgB,cAAAA,WAAW,EAAE;AADf,aAlBY;AAXT,WAAP;AAkCD;AAzCH,OAFU,EA6CV;AACET,QAAAA,QAAQ,EAAG,uCAAsCpC,gBAAgB,CAC/DM,IAD+D,CAE/D,uGAAsGL,sBAAsB,CAC5HK,IAD4H,EAE5H;AACEY,UAAAA,IAAI,EAAE;AADR,SAF4H,CAK5H,EARJ;AASE4B,QAAAA,gBAAgB,EAAE,IATpB;AAUEC,QAAAA,qBAAqB,EAAE,IAVzB;AAWEC,QAAAA,QAAQ,EAAE/B,QAXZ;AAYEqB,QAAAA,QAAQ,EAAEtB,QAZZ;AAaEuB,QAAAA,eAAe,EAAEjC;AAbnB,OA7CU,CAAZ;AA6DD,KAhJD;AAiJA,WAAOrB,CAAP;AACD,GAxKH,EAyKE,CAAC,4BAAD,CAzKF,EA0KE,EA1KF,EA2KE,CAAC,SAAD,CA3KF;AA6KD,C","sourcesContent":["// @flow\nimport type { Plugin } from \"graphile-build\";\n\nconst base64 = str => Buffer.from(String(str)).toString(\"base64\");\n\nexport default (function PgScalarFunctionConnectionPlugin(builder) {\n builder.hook(\n \"init\",\n (_, build) => {\n const {\n newWithHooks,\n pgIntrospectionResultsByKind: introspectionResultsByKind,\n getTypeByName,\n pgGetGqlTypeByTypeIdAndModifier,\n graphql: {\n GraphQLObjectType,\n GraphQLNonNull,\n GraphQLList,\n GraphQLString,\n },\n inflection,\n pgOmit: omit,\n describePgEntity,\n sqlCommentByAddingTags,\n pgField,\n } = build;\n\n const Cursor = getTypeByName(\"Cursor\");\n introspectionResultsByKind.procedure.forEach(proc => {\n // PERFORMANCE: These used to be .filter(...) calls\n if (!proc.returnsSet) return;\n if (!proc.namespace) return;\n if (omit(proc, \"execute\")) return;\n\n const returnType =\n introspectionResultsByKind.typeById[proc.returnTypeId];\n const returnTypeTable =\n introspectionResultsByKind.classById[returnType.classId];\n if (returnTypeTable) {\n // Just use the standard table connection from PgTablesPlugin\n return;\n }\n if (returnType.id === \"2249\") {\n // Defer handling to PgRecordFunctionConnectionPlugin\n return;\n }\n // TODO: PG10 doesn't support the equivalent of pg_attribute.atttypemod\n // on function arguments and return types, however maybe a later\n // version of PG will?\n const NodeType =\n pgGetGqlTypeByTypeIdAndModifier(returnType.id, null) || GraphQLString;\n const EdgeType = newWithHooks(\n GraphQLObjectType,\n {\n name: inflection.scalarFunctionEdge(proc),\n description: build.wrapDescription(\n `A \\`${NodeType.name}\\` edge in the connection.`,\n \"type\"\n ),\n fields: ({ fieldWithHooks }) => {\n return {\n cursor: fieldWithHooks(\n \"cursor\",\n ({ addDataGenerator }) => {\n addDataGenerator(() => ({\n usesCursor: [true],\n }));\n return {\n description: build.wrapDescription(\n \"A cursor for use in pagination.\",\n \"field\"\n ),\n type: Cursor,\n resolve(data) {\n return base64(JSON.stringify(data.__cursor));\n },\n };\n },\n {\n isCursorField: true,\n }\n ),\n node: {\n description: build.wrapDescription(\n `The \\`${NodeType.name}\\` at the end of the edge.`,\n \"field\"\n ),\n type: NodeType,\n resolve(data) {\n return data.value;\n },\n },\n };\n },\n },\n {\n __origin: `Adding function result edge type for ${describePgEntity(\n proc\n )}. You can rename the function's GraphQL field (and its dependent types) via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n proc,\n {\n name: \"newNameHere\",\n }\n )}`,\n isEdgeType: true,\n nodeType: NodeType,\n pgIntrospection: proc,\n }\n );\n\n /*const ConnectionType = */\n newWithHooks(\n GraphQLObjectType,\n {\n name: inflection.scalarFunctionConnection(proc),\n description: build.wrapDescription(\n `A connection to a list of \\`${NodeType.name}\\` values.`,\n \"type\"\n ),\n fields: ({ fieldWithHooks }) => {\n return {\n nodes: pgField(build, fieldWithHooks, \"nodes\", {\n description: build.wrapDescription(\n `A list of \\`${NodeType.name}\\` objects.`,\n \"field\"\n ),\n type: new GraphQLNonNull(new GraphQLList(NodeType)),\n resolve(data) {\n return data.data.map(entry => entry.value);\n },\n }),\n edges: pgField(\n build,\n fieldWithHooks,\n \"edges\",\n {\n description: build.wrapDescription(\n `A list of edges which contains the \\`${NodeType.name}\\` and cursor to aid in pagination.`,\n \"field\"\n ),\n type: new GraphQLNonNull(\n new GraphQLList(new GraphQLNonNull(EdgeType))\n ),\n resolve(data) {\n return data.data;\n },\n },\n {},\n false,\n {\n hoistCursor: true,\n }\n ),\n };\n },\n },\n {\n __origin: `Adding function connection type for ${describePgEntity(\n proc\n )}. You can rename the function's GraphQL field (and its dependent types) via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n proc,\n {\n name: \"newNameHere\",\n }\n )}`,\n isConnectionType: true,\n isPgRowConnectionType: true,\n edgeType: EdgeType,\n nodeType: NodeType,\n pgIntrospection: proc,\n }\n );\n });\n return _;\n },\n [\"PgScalarFunctionConnection\"],\n [],\n [\"PgTypes\"]\n );\n}: Plugin);\n"],"file":"PgScalarFunctionConnectionPlugin.js"}
@@ -121,7 +121,7 @@ var PgTablesPlugin = function PgTablesPlugin(builder, {
121
121
  };
122
122
  });
123
123
  fields[nodeIdFieldName] = {
124
- description: "A globally unique identifier. Can be used in various places throughout the system to identify this single value.",
124
+ description: build.wrapDescription("A globally unique identifier. Can be used in various places throughout the system to identify this single value.", "field"),
125
125
  type: new GraphQLNonNull(GraphQLID),
126
126
 
127
127
  resolve(data) {
@@ -184,7 +184,7 @@ var PgTablesPlugin = function PgTablesPlugin(builder, {
184
184
  const pgPatchInputFields = {};
185
185
  const pgBaseInputFields = {};
186
186
  newWithHooks(GraphQLInputObjectType, {
187
- description: `An input for mutations affecting \`${tableTypeName}\``,
187
+ description: build.wrapDescription(`An input for mutations affecting \`${tableTypeName}\``, "type"),
188
188
  name: inflection.inputType(TableType)
189
189
  }, {
190
190
  __origin: `Adding table input type for ${describePgEntity(table)}. You can rename the table's GraphQL type via a 'Smart Comment':\n\n ${sqlCommentByAddingTags(table, {
@@ -214,7 +214,7 @@ var PgTablesPlugin = function PgTablesPlugin(builder, {
214
214
  // approach is to use the modifier to specify the type you need,
215
215
  // 'patch' or 'base', so they can be registered just in time.
216
216
  TablePatchType = newWithHooks(GraphQLInputObjectType, {
217
- description: `Represents an update to a \`${tableTypeName}\`. Fields that are set will be updated.`,
217
+ description: build.wrapDescription(`Represents an update to a \`${tableTypeName}\`. Fields that are set will be updated.`, "type"),
218
218
  name: inflection.patchType(TableType)
219
219
  }, {
220
220
  __origin: `Adding table patch type for ${describePgEntity(table)}. You can rename the table's GraphQL type via a 'Smart Comment':\n\n ${sqlCommentByAddingTags(table, {
@@ -237,7 +237,7 @@ var PgTablesPlugin = function PgTablesPlugin(builder, {
237
237
  }, true // Safe to skip this if no fields support updating
238
238
  );
239
239
  TableBaseInputType = newWithHooks(GraphQLInputObjectType, {
240
- description: `An input representation of \`${tableTypeName}\` with nullable fields.`,
240
+ description: build.wrapDescription(`An input representation of \`${tableTypeName}\` with nullable fields.`, "type"),
241
241
  name: inflection.baseInputType(TableType)
242
242
  }, {
243
243
  __origin: `Adding table base input type for ${describePgEntity(table)}. You can rename the table's GraphQL type via a 'Smart Comment':\n\n ${sqlCommentByAddingTags(table, {
@@ -284,17 +284,17 @@ var PgTablesPlugin = function PgTablesPlugin(builder, {
284
284
  type,
285
285
  typeModifier
286
286
  } = inputField;
287
- return sql.fragment`${gql2pg(v, type, typeModifier)}::${sql.identifier(type.namespaceName, type.name)}`;
287
+ return sql.fragment`${gql2pg(v, type, typeModifier)}::${type.isFake ? sql.identifier("unknown") : sql.identifier(type.namespaceName, type.name)}`;
288
288
  } else {
289
289
  return sql.null; // TODO: return default instead.
290
290
  }
291
291
  };
292
292
 
293
- return sql.fragment`row(${sql.join(attributes.map(attr2sql), ",")})::${sql.identifier(tablePgType.namespaceName, tablePgType.name)}`;
293
+ return sql.fragment`row(${sql.join(attributes.map(attr2sql), ",")})::${tablePgType.isFake ? sql.identifier("unknown") : sql.identifier(tablePgType.namespaceName, tablePgType.name)}`;
294
294
  }
295
295
  };
296
296
  const EdgeType = newWithHooks(GraphQLObjectType, {
297
- description: `A \`${tableTypeName}\` edge in the connection.`,
297
+ description: build.wrapDescription(`A \`${tableTypeName}\` edge in the connection.`, "type"),
298
298
  name: inflection.edge(TableType.name),
299
299
  fields: ({
300
300
  fieldWithHooks
@@ -312,7 +312,7 @@ var PgTablesPlugin = function PgTablesPlugin(builder, {
312
312
  }
313
313
  }));
314
314
  return {
315
- description: "A cursor for use in pagination.",
315
+ description: build.wrapDescription("A cursor for use in pagination.", "field"),
316
316
  type: Cursor,
317
317
 
318
318
  resolve(data) {
@@ -324,7 +324,7 @@ var PgTablesPlugin = function PgTablesPlugin(builder, {
324
324
  isCursorField: true
325
325
  }),
326
326
  node: pgField(build, fieldWithHooks, "node", {
327
- description: `The \`${tableTypeName}\` at the end of the edge.`,
327
+ description: build.wrapDescription(`The \`${tableTypeName}\` at the end of the edge.`, "field"),
328
328
  type: nullableIf(!pgForbidSetofFunctionsToReturnNull, TableType),
329
329
 
330
330
  resolve(data, _args, resolveContext, resolveInfo) {
@@ -361,7 +361,7 @@ var PgTablesPlugin = function PgTablesPlugin(builder, {
361
361
  /*const ConnectionType = */
362
362
 
363
363
  newWithHooks(GraphQLObjectType, {
364
- description: `A connection to a list of \`${tableTypeName}\` values.`,
364
+ description: build.wrapDescription(`A connection to a list of \`${tableTypeName}\` values.`, "type"),
365
365
  name: inflection.connection(TableType.name),
366
366
  fields: ({
367
367
  recurseDataGeneratorsForField,
@@ -370,7 +370,7 @@ var PgTablesPlugin = function PgTablesPlugin(builder, {
370
370
  recurseDataGeneratorsForField("pageInfo", true);
371
371
  return {
372
372
  nodes: pgField(build, fieldWithHooks, "nodes", {
373
- description: `A list of \`${tableTypeName}\` objects.`,
373
+ description: build.wrapDescription(`A list of \`${tableTypeName}\` objects.`, "field"),
374
374
  type: new GraphQLNonNull(new GraphQLList(nullableIf(!pgForbidSetofFunctionsToReturnNull, TableType))),
375
375
 
376
376
  resolve(data, _args, resolveContext, resolveInfo) {
@@ -395,7 +395,7 @@ var PgTablesPlugin = function PgTablesPlugin(builder, {
395
395
  }
396
396
  }),
397
397
  edges: pgField(build, fieldWithHooks, "edges", {
398
- description: `A list of edges which contains the \`${tableTypeName}\` and cursor to aid in pagination.`,
398
+ description: build.wrapDescription(`A list of edges which contains the \`${tableTypeName}\` and cursor to aid in pagination.`, "field"),
399
399
  type: new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(EdgeType))),
400
400
 
401
401
  resolve(data, _args, _context, resolveInfo) {
@@ -409,7 +409,7 @@ var PgTablesPlugin = function PgTablesPlugin(builder, {
409
409
  hoistCursor: true
410
410
  }),
411
411
  pageInfo: PageInfo && {
412
- description: "Information to aid in pagination.",
412
+ description: build.wrapDescription("Information to aid in pagination.", "field"),
413
413
  type: new GraphQLNonNull(PageInfo),
414
414
 
415
415
  resolve(data) {
@@ -128,8 +128,10 @@ export default (function PgTablesPlugin(
128
128
  };
129
129
  });
130
130
  fields[nodeIdFieldName] = {
131
- description:
131
+ description: build.wrapDescription(
132
132
  "A globally unique identifier. Can be used in various places throughout the system to identify this single value.",
133
+ "field"
134
+ ),
133
135
  type: new GraphQLNonNull(GraphQLID),
134
136
  resolve(data) {
135
137
  const identifiers = data.__identifiers;
@@ -197,7 +199,10 @@ export default (function PgTablesPlugin(
197
199
  newWithHooks(
198
200
  GraphQLInputObjectType,
199
201
  {
200
- description: `An input for mutations affecting \`${tableTypeName}\``,
202
+ description: build.wrapDescription(
203
+ `An input for mutations affecting \`${tableTypeName}\``,
204
+ "type"
205
+ ),
201
206
  name: inflection.inputType(TableType),
202
207
  },
203
208
  {
@@ -234,7 +239,10 @@ export default (function PgTablesPlugin(
234
239
  TablePatchType = newWithHooks(
235
240
  GraphQLInputObjectType,
236
241
  {
237
- description: `Represents an update to a \`${tableTypeName}\`. Fields that are set will be updated.`,
242
+ description: build.wrapDescription(
243
+ `Represents an update to a \`${tableTypeName}\`. Fields that are set will be updated.`,
244
+ "type"
245
+ ),
238
246
  name: inflection.patchType(TableType),
239
247
  },
240
248
  {
@@ -270,7 +278,10 @@ export default (function PgTablesPlugin(
270
278
  TableBaseInputType = newWithHooks(
271
279
  GraphQLInputObjectType,
272
280
  {
273
- description: `An input representation of \`${tableTypeName}\` with nullable fields.`,
281
+ description: build.wrapDescription(
282
+ `An input representation of \`${tableTypeName}\` with nullable fields.`,
283
+ "type"
284
+ ),
274
285
  name: inflection.baseInputType(TableType),
275
286
  },
276
287
  {
@@ -323,11 +334,11 @@ export default (function PgTablesPlugin(
323
334
  const v = obj[fieldName];
324
335
  if (inputField && v != null) {
325
336
  const { type, typeModifier } = inputField;
326
- return sql.fragment`${gql2pg(
327
- v,
328
- type,
329
- typeModifier
330
- )}::${sql.identifier(type.namespaceName, type.name)}`;
337
+ return sql.fragment`${gql2pg(v, type, typeModifier)}::${
338
+ type.isFake
339
+ ? sql.identifier("unknown")
340
+ : sql.identifier(type.namespaceName, type.name)
341
+ }`;
331
342
  } else {
332
343
  return sql.null; // TODO: return default instead.
333
344
  }
@@ -336,17 +347,24 @@ export default (function PgTablesPlugin(
336
347
  return sql.fragment`row(${sql.join(
337
348
  attributes.map(attr2sql),
338
349
  ","
339
- )})::${sql.identifier(
340
- tablePgType.namespaceName,
341
- tablePgType.name
342
- )}`;
350
+ )})::${
351
+ tablePgType.isFake
352
+ ? sql.identifier("unknown")
353
+ : sql.identifier(
354
+ tablePgType.namespaceName,
355
+ tablePgType.name
356
+ )
357
+ }`;
343
358
  },
344
359
  };
345
360
 
346
361
  const EdgeType = newWithHooks(
347
362
  GraphQLObjectType,
348
363
  {
349
- description: `A \`${tableTypeName}\` edge in the connection.`,
364
+ description: build.wrapDescription(
365
+ `A \`${tableTypeName}\` edge in the connection.`,
366
+ "type"
367
+ ),
350
368
  name: inflection.edge(TableType.name),
351
369
  fields: ({ fieldWithHooks }) => {
352
370
  return {
@@ -362,7 +380,10 @@ export default (function PgTablesPlugin(
362
380
  },
363
381
  }));
364
382
  return {
365
- description: "A cursor for use in pagination.",
383
+ description: build.wrapDescription(
384
+ "A cursor for use in pagination.",
385
+ "field"
386
+ ),
366
387
  type: Cursor,
367
388
  resolve(data) {
368
389
  return (
@@ -381,7 +402,10 @@ export default (function PgTablesPlugin(
381
402
  fieldWithHooks,
382
403
  "node",
383
404
  {
384
- description: `The \`${tableTypeName}\` at the end of the edge.`,
405
+ description: build.wrapDescription(
406
+ `The \`${tableTypeName}\` at the end of the edge.`,
407
+ "field"
408
+ ),
385
409
  type: nullableIf(
386
410
  !pgForbidSetofFunctionsToReturnNull,
387
411
  TableType
@@ -442,7 +466,10 @@ export default (function PgTablesPlugin(
442
466
  newWithHooks(
443
467
  GraphQLObjectType,
444
468
  {
445
- description: `A connection to a list of \`${tableTypeName}\` values.`,
469
+ description: build.wrapDescription(
470
+ `A connection to a list of \`${tableTypeName}\` values.`,
471
+ "type"
472
+ ),
446
473
  name: inflection.connection(TableType.name),
447
474
  fields: ({ recurseDataGeneratorsForField, fieldWithHooks }) => {
448
475
  recurseDataGeneratorsForField("pageInfo", true);
@@ -452,7 +479,10 @@ export default (function PgTablesPlugin(
452
479
  fieldWithHooks,
453
480
  "nodes",
454
481
  {
455
- description: `A list of \`${tableTypeName}\` objects.`,
482
+ description: build.wrapDescription(
483
+ `A list of \`${tableTypeName}\` objects.`,
484
+ "field"
485
+ ),
456
486
  type: new GraphQLNonNull(
457
487
  new GraphQLList(
458
488
  nullableIf(
@@ -505,7 +535,10 @@ export default (function PgTablesPlugin(
505
535
  fieldWithHooks,
506
536
  "edges",
507
537
  {
508
- description: `A list of edges which contains the \`${tableTypeName}\` and cursor to aid in pagination.`,
538
+ description: build.wrapDescription(
539
+ `A list of edges which contains the \`${tableTypeName}\` and cursor to aid in pagination.`,
540
+ "field"
541
+ ),
509
542
  type: new GraphQLNonNull(
510
543
  new GraphQLList(new GraphQLNonNull(EdgeType))
511
544
  ),
@@ -526,7 +559,10 @@ export default (function PgTablesPlugin(
526
559
  }
527
560
  ),
528
561
  pageInfo: PageInfo && {
529
- description: "Information to aid in pagination.",
562
+ description: build.wrapDescription(
563
+ "Information to aid in pagination.",
564
+ "field"
565
+ ),
530
566
  type: new GraphQLNonNull(PageInfo),
531
567
  resolve(data) {
532
568
  return data;