Skip to content

Commit

Permalink
fix(graphql): --no-setof-functions-contain-nulls now applies to simpl…
Browse files Browse the repository at this point in the history
…e collections too (#441)
  • Loading branch information
benjie committed Apr 13, 2019
1 parent 2db5472 commit a3f118d
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 36 deletions.
16 changes: 13 additions & 3 deletions packages/graphile-build-pg/src/plugins/makeProcField.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export default function makeProcField(
describePgEntity,
sqlCommentByAddingTags,
pgField,
options: { subscriptions = false },
options: {
subscriptions = false,
pgForbidSetofFunctionsToReturnNull = false,
},
} = build;

if (computed && isMutation) {
Expand Down Expand Up @@ -184,9 +187,15 @@ export default function makeProcField(
if (isTableLike) {
if (proc.returnsSet) {
if (isMutation) {
type = new GraphQLList(TableType);
const innerType = pgForbidSetofFunctionsToReturnNull
? new GraphQLNonNull(TableType)
: TableType;
type = new GraphQLList(innerType);
} else if (forceList) {
type = new GraphQLList(TableType);
const innerType = pgForbidSetofFunctionsToReturnNull
? new GraphQLNonNull(TableType)
: TableType;
type = new GraphQLList(innerType);
fieldScope.isPgFieldSimpleCollection = true;
} else {
const ConnectionType = getTypeByName(
Expand All @@ -207,6 +216,7 @@ export default function makeProcField(
} else {
type = TableType;
if (rawReturnType.isPgArray) {
// Not implementing pgForbidSetofFunctionsToReturnNull here because it's not a set
type = new GraphQLList(type);
}
fieldScope.pgFieldIntrospectionTable = returnTypeTable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ type Issue756SetMutationPayload {
\\"\\"\\"The method to use when ordering \`Issue756\`.\\"\\"\\"
orderBy: [Issue756SOrderBy!] = [PRIMARY_KEY_ASC]
): Issue756SEdge
issue756S: [Issue756]
issue756S: [Issue756!]
\\"\\"\\"
Our root query field type. Allows us to run any query from our mutation payload.
Expand Down Expand Up @@ -2454,7 +2454,7 @@ type MutationOutTableSetofPayload {
unchanged and unused. May be used by a client to track mutations.
\\"\\"\\"
clientMutationId: String
people: [Person]
people: [Person!]
\\"\\"\\"An edge for our \`Person\`. May be used by Relay 1.\\"\\"\\"
personEdge(
Expand Down Expand Up @@ -3798,7 +3798,7 @@ type TableSetMutationPayload {
unchanged and unused. May be used by a client to track mutations.
\\"\\"\\"
clientMutationId: String
people: [Person]
people: [Person!]
\\"\\"\\"An edge for our \`Person\`. May be used by Relay 1.\\"\\"\\"
personEdge(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ type Issue756SetMutationPayload {
\\"\\"\\"The method to use when ordering \`Issue756\`.\\"\\"\\"
orderBy: [Issue756SOrderBy!] = [PRIMARY_KEY_ASC]
): Issue756SEdge
issue756S: [Issue756]
issue756S: [Issue756!]
\\"\\"\\"
Our root query field type. Allows us to run any query from our mutation payload.
Expand Down Expand Up @@ -2454,7 +2454,7 @@ type MutationOutTableSetofPayload {
unchanged and unused. May be used by a client to track mutations.
\\"\\"\\"
clientMutationId: String
people: [Person]
people: [Person!]
\\"\\"\\"An edge for our \`Person\`. May be used by Relay 1.\\"\\"\\"
personEdge(
Expand Down Expand Up @@ -3850,7 +3850,7 @@ type TableSetMutationPayload {
unchanged and unused. May be used by a client to track mutations.
\\"\\"\\"
clientMutationId: String
people: [Person]
people: [Person!]
\\"\\"\\"An edge for our \`Person\`. May be used by Relay 1.\\"\\"\\"
personEdge(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ type Issue756SetMutationPayload {
\\"\\"\\"The method to use when ordering \`Issue756\`.\\"\\"\\"
orderBy: [Issue756SOrderBy!] = [PRIMARY_KEY_ASC]
): Issue756SEdge
issue756S: [Issue756]
issue756S: [Issue756!]
\\"\\"\\"
Our root query field type. Allows us to run any query from our mutation payload.
Expand Down Expand Up @@ -1414,7 +1414,7 @@ type MutationOutTableSetofPayload {
unchanged and unused. May be used by a client to track mutations.
\\"\\"\\"
clientMutationId: String
people: [Person]
people: [Person!]
\\"\\"\\"An edge for our \`Person\`. May be used by Relay 1.\\"\\"\\"
personEdge(
Expand Down Expand Up @@ -2706,7 +2706,7 @@ type TableSetMutationPayload {
unchanged and unused. May be used by a client to track mutations.
\\"\\"\\"
clientMutationId: String
people: [Person]
people: [Person!]
\\"\\"\\"An edge for our \`Person\`. May be used by Relay 1.\\"\\"\\"
personEdge(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2399,7 +2399,7 @@ type PostManyPayload {
\\"\\"\\"The method to use when ordering \`Post\`.\\"\\"\\"
orderBy: [PostsOrderBy!] = [PRIMARY_KEY_ASC]
): PostsEdge
posts: [Post]
posts: [Post!]
\\"\\"\\"
Our root query field type. Allows us to run any query from our mutation payload.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ type Issue756SetMutationPayload {
\\"\\"\\"The method to use when ordering \`Issue756\`.\\"\\"\\"
orderBy: [Issue756SOrderBy!] = [PRIMARY_KEY_ASC]
): Issue756SEdge
issue756S: [Issue756]
issue756S: [Issue756!]
\\"\\"\\"
Our root query field type. Allows us to run any query from our mutation payload.
Expand Down Expand Up @@ -2455,7 +2455,7 @@ type MutationOutTableSetofPayload {
unchanged and unused. May be used by a client to track mutations.
\\"\\"\\"
clientMutationId: String
people: [Person]
people: [Person!]
\\"\\"\\"An edge for our \`Person\`. May be used by Relay 1.\\"\\"\\"
personEdge(
Expand Down Expand Up @@ -3831,7 +3831,7 @@ type TableSetMutationPayload {
unchanged and unused. May be used by a client to track mutations.
\\"\\"\\"
clientMutationId: String
people: [Person]
people: [Person!]
\\"\\"\\"An edge for our \`Person\`. May be used by Relay 1.\\"\\"\\"
personEdge(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ type Issue756SetMutationPayload {
\\"\\"\\"The method to use when ordering \`Issue756\`.\\"\\"\\"
orderBy: [Issue756SOrderBy!] = [PRIMARY_KEY_ASC]
): Issue756SEdge
issue756S: [Issue756]
issue756S: [Issue756!]
\\"\\"\\"
Our root query field type. Allows us to run any query from our mutation payload.
Expand Down Expand Up @@ -2457,7 +2457,7 @@ type MutationOutTableSetofPayload {
unchanged and unused. May be used by a client to track mutations.
\\"\\"\\"
clientMutationId: String
people: [Person]
people: [Person!]
\\"\\"\\"An edge for our \`Person\`. May be used by Relay 1.\\"\\"\\"
personEdge(
Expand Down Expand Up @@ -2997,7 +2997,7 @@ type Person implements Node {
\\"\\"\\"The method to use when ordering \`Person\`.\\"\\"\\"
orderBy: [PeopleOrderBy!]
): [Person]
): [Person!]
\\"\\"\\"The primary unique identifier for the person\\"\\"\\"
id: Int!
Expand Down Expand Up @@ -3105,7 +3105,7 @@ type Person implements Node {
\\"\\"\\"Skip the first \`n\` values.\\"\\"\\"
offset: Int
): [Type]
): [Type!]
typeFunctionList: [Type]
}
Expand Down Expand Up @@ -3699,7 +3699,7 @@ type Query implements Node {
\\"\\"\\"Skip the first \`n\` values.\\"\\"\\"
offset: Int
): [Person] @deprecated(reason: \\"This is deprecated (comment on function c.badly_behaved_function).\\")
): [Person!] @deprecated(reason: \\"This is deprecated (comment on function c.badly_behaved_function).\\")
\\"\\"\\"Reads a single \`CompoundKey\` using its globally unique \`ID\`.\\"\\"\\"
compoundKey(
Expand Down Expand Up @@ -3738,7 +3738,7 @@ type Query implements Node {
\\"\\"\\"Skip the first \`n\` values.\\"\\"\\"
offset: Int
): [CompoundType]
): [CompoundType!]
currentUserId: Int
funcInInout(i: Int, ino: Int): Int
funcInOut(i: Int): Int
Expand Down Expand Up @@ -3861,7 +3861,7 @@ type Query implements Node {
\\"\\"\\"Skip the first \`n\` values.\\"\\"\\"
offset: Int
): [Person]
): [Person!]
funcOutUnnamed: Int
funcOutUnnamedOutOutUnnamed: FuncOutUnnamedOutOutUnnamedRecord
funcReturnsTableMultiCol(
Expand Down Expand Up @@ -4068,7 +4068,7 @@ type Query implements Node {
\\"\\"\\"The method to use when ordering \`Person\`.\\"\\"\\"
orderBy: [PeopleOrderBy!]
): [Person]
): [Person!]
typesQuery(a: BigInt!, b: Boolean!, c: String!, d: [Int]!, e: JSON!, f: FloatRangeInput!): Boolean
}
Expand Down Expand Up @@ -4120,7 +4120,7 @@ type TableSetMutationPayload {
unchanged and unused. May be used by a client to track mutations.
\\"\\"\\"
clientMutationId: String
people: [Person]
people: [Person!]
\\"\\"\\"An edge for our \`Person\`. May be used by Relay 1.\\"\\"\\"
personEdge(
Expand Down Expand Up @@ -5713,7 +5713,7 @@ type Issue756SetMutationPayload {
unchanged and unused. May be used by a client to track mutations.
\\"\\"\\"
clientMutationId: String
issue756S: [Issue756]
issue756S: [Issue756!]
\\"\\"\\"
Our root query field type. Allows us to run any query from our mutation payload.
Expand Down Expand Up @@ -6779,7 +6779,7 @@ type MutationOutTableSetofPayload {
unchanged and unused. May be used by a client to track mutations.
\\"\\"\\"
clientMutationId: String
people: [Person]
people: [Person!]
\\"\\"\\"
Our root query field type. Allows us to run any query from our mutation payload.
Expand Down Expand Up @@ -7138,7 +7138,7 @@ type Person implements Node {
\\"\\"\\"The method to use when ordering \`Person\`.\\"\\"\\"
orderBy: [PeopleOrderBy!]
): [Person]
): [Person!]
\\"\\"\\"The primary unique identifier for the person\\"\\"\\"
id: Int!
Expand Down Expand Up @@ -7167,7 +7167,7 @@ type Person implements Node {
\\"\\"\\"Skip the first \`n\` values.\\"\\"\\"
offset: Int
): [Type]
): [Type!]
typeFunctionList: [Type]
}
Expand Down Expand Up @@ -7482,7 +7482,7 @@ type Query implements Node {
\\"\\"\\"Skip the first \`n\` values.\\"\\"\\"
offset: Int
): [Person] @deprecated(reason: \\"This is deprecated (comment on function c.badly_behaved_function).\\")
): [Person!] @deprecated(reason: \\"This is deprecated (comment on function c.badly_behaved_function).\\")
\\"\\"\\"Reads a single \`CompoundKey\` using its globally unique \`ID\`.\\"\\"\\"
compoundKey(
Expand All @@ -7500,7 +7500,7 @@ type Query implements Node {
\\"\\"\\"Skip the first \`n\` values.\\"\\"\\"
offset: Int
): [CompoundType]
): [CompoundType!]
currentUserId: Int
funcInInout(i: Int, ino: Int): Int
funcInOut(i: Int): Int
Expand Down Expand Up @@ -7542,7 +7542,7 @@ type Query implements Node {
\\"\\"\\"Skip the first \`n\` values.\\"\\"\\"
offset: Int
): [Person]
): [Person!]
funcOutUnnamed: Int
funcOutUnnamedOutOutUnnamed: FuncOutUnnamedOutOutUnnamedRecord
funcReturnsTableMultiColList(
Expand Down Expand Up @@ -7658,7 +7658,7 @@ type Query implements Node {
\\"\\"\\"The method to use when ordering \`Person\`.\\"\\"\\"
orderBy: [PeopleOrderBy!]
): [Person]
): [Person!]
typesQuery(a: BigInt!, b: Boolean!, c: String!, d: [Int]!, e: JSON!, f: FloatRangeInput!): Boolean
}
Expand Down Expand Up @@ -7710,7 +7710,7 @@ type TableSetMutationPayload {
unchanged and unused. May be used by a client to track mutations.
\\"\\"\\"
clientMutationId: String
people: [Person]
people: [Person!]
\\"\\"\\"
Our root query field type. Allows us to run any query from our mutation payload.
Expand Down Expand Up @@ -8533,7 +8533,7 @@ type Person implements Node {
\\"\\"\\"Skip the first \`n\` values.\\"\\"\\"
offset: Int
): [Pet]
): [Pet!]
\\"\\"\\"Reads and enables pagination through a set of \`Pet\`.\\"\\"\\"
petsByOwnerIdList(
Expand Down Expand Up @@ -9163,7 +9163,7 @@ type Person implements Node {
\\"\\"\\"Skip the first \`n\` values.\\"\\"\\"
offset: Int
): [Pet]
): [Pet!]
\\"\\"\\"Reads and enables pagination through a set of \`Pet\`.\\"\\"\\"
petsByOwnerId(
Expand Down

0 comments on commit a3f118d

Please sign in to comment.