Skip to content

Commit

Permalink
fix: remove sortable/filterable from functions with required args (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbretl authored and benjie committed Sep 11, 2019
1 parent 1a9dc17 commit 2335d6e
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function getCompatibleComputedColumns(build, table) {
const { pseudoColumnName } = computedColumnDetails;

// Must have only one required argument
const nonOptionalArgumentsCount = proc.argDefaultsNum - proc.inputArgsCount;
const nonOptionalArgumentsCount = proc.inputArgsCount - proc.argDefaultsNum;
if (nonOptionalArgumentsCount > 1) {
return memo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default (function PgOrderComputedColumnsPlugin(builder) {

// Must have only one required argument
const nonOptionalArgumentsCount =
proc.argDefaultsNum - proc.inputArgsCount;
proc.inputArgsCount - proc.argDefaultsNum;
if (nonOptionalArgumentsCount > 1) {
return memo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6213,6 +6213,8 @@ type Post implements Node {
offset: Int
): PostComputedIntervalSetConnection!
computedTextArray: [String]
computedWithOptionalArg(i: Int): Int
computedWithRequiredArg(i: Int!): Int
enums: [AnEnum]
headline: String!
headlineTrimmed(length: Int, omission: String): String
Expand Down Expand Up @@ -6323,6 +6325,9 @@ input PostCondition {
\\"\\"\\"Checks for equality with the object’s \`comptypes\` field.\\"\\"\\"
comptypes: [ComptypeInput]

\\"\\"\\"Checks for equality with the object’s \`computedWithOptionalArg\` field.\\"\\"\\"
computedWithOptionalArg: Int

\\"\\"\\"Checks for equality with the object’s \`enums\` field.\\"\\"\\"
enums: [AnEnum]

Expand Down Expand Up @@ -6412,6 +6417,8 @@ enum PostsOrderBy {
BODY_DESC
COMPTYPES_ASC
COMPTYPES_DESC
COMPUTED_WITH_OPTIONAL_ARG_ASC
COMPUTED_WITH_OPTIONAL_ARG_DESC
ENUMS_ASC
ENUMS_DESC
HEADLINE_ASC
Expand Down Expand Up @@ -16192,6 +16199,8 @@ type Post implements Node {
offset: Int
): PostComputedIntervalSetConnection!
computedTextArray: [String]
computedWithOptionalArg(i: Int): Int
computedWithRequiredArg(i: Int!): Int
enums: [AnEnum]
headline: String!
headlineTrimmed(length: Int, omission: String): String
Expand Down Expand Up @@ -16302,6 +16311,9 @@ input PostCondition {
\\"\\"\\"Checks for equality with the object’s \`comptypes\` field.\\"\\"\\"
comptypes: [ComptypeInput]

\\"\\"\\"Checks for equality with the object’s \`computedWithOptionalArg\` field.\\"\\"\\"
computedWithOptionalArg: Int

\\"\\"\\"Checks for equality with the object’s \`enums\` field.\\"\\"\\"
enums: [AnEnum]

Expand Down Expand Up @@ -16391,6 +16403,8 @@ enum PostsOrderBy {
BODY_DESC
COMPTYPES_ASC
COMPTYPES_DESC
COMPUTED_WITH_OPTIONAL_ARG_ASC
COMPUTED_WITH_OPTIONAL_ARG_DESC
ENUMS_ASC
ENUMS_DESC
HEADLINE_ASC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6213,6 +6213,8 @@ type Post implements Node {
offset: Int
): PostComputedIntervalSetConnection!
computedTextArray: [String]
computedWithOptionalArg(i: Int): Int
computedWithRequiredArg(i: Int!): Int
enums: [AnEnum]
headline: String!
headlineTrimmed(length: Int, omission: String): String
Expand Down Expand Up @@ -6323,6 +6325,9 @@ input PostCondition {
\\"\\"\\"Checks for equality with the object’s \`comptypes\` field.\\"\\"\\"
comptypes: [ComptypeInput]
\\"\\"\\"Checks for equality with the object’s \`computedWithOptionalArg\` field.\\"\\"\\"
computedWithOptionalArg: Int
\\"\\"\\"Checks for equality with the object’s \`enums\` field.\\"\\"\\"
enums: [AnEnum]
Expand Down Expand Up @@ -6412,6 +6417,8 @@ enum PostsOrderBy {
BODY_DESC
COMPTYPES_ASC
COMPTYPES_DESC
COMPUTED_WITH_OPTIONAL_ARG_ASC
COMPUTED_WITH_OPTIONAL_ARG_DESC
ENUMS_ASC
ENUMS_DESC
HEADLINE_ASC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6458,6 +6458,8 @@ type Post implements Node {
offset: Int
): PostComputedIntervalSetConnection!
computedTextArray: [String]
computedWithOptionalArg(i: Int): Int
computedWithRequiredArg(i: Int!): Int
enums: [AnEnum]
headline: String!
headlineTrimmed(length: Int, omission: String): String
Expand Down Expand Up @@ -6562,6 +6564,9 @@ input PostCondition {
\\"\\"\\"Checks for equality with the object’s \`authorId\` field.\\"\\"\\"
authorId: Int
\\"\\"\\"Checks for equality with the object’s \`computedWithOptionalArg\` field.\\"\\"\\"
computedWithOptionalArg: Int
\\"\\"\\"Checks for equality with the object’s \`id\` field.\\"\\"\\"
id: Int
}
Expand Down Expand Up @@ -6641,6 +6646,8 @@ type PostsEdge {
enum PostsOrderBy {
AUTHOR_ID_ASC
AUTHOR_ID_DESC
COMPUTED_WITH_OPTIONAL_ARG_ASC
COMPUTED_WITH_OPTIONAL_ARG_DESC
ID_ASC
ID_DESC
NATURAL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6213,6 +6213,8 @@ type Post implements N {
offset: Int
): PostComputedIntervalSetConnection!
computedTextArray: [String]
computedWithOptionalArg(i: Int): Int
computedWithRequiredArg(i: Int!): Int
enums: [AnEnum]
headline: String!
headlineTrimmed(length: Int, omission: String): String
Expand Down Expand Up @@ -6323,6 +6325,9 @@ input PostCondition {
\\"\\"\\"Checks for equality with the object’s \`comptypes\` field.\\"\\"\\"
comptypes: [ComptypeInput]
\\"\\"\\"Checks for equality with the object’s \`computedWithOptionalArg\` field.\\"\\"\\"
computedWithOptionalArg: Int
\\"\\"\\"Checks for equality with the object’s \`enums\` field.\\"\\"\\"
enums: [AnEnum]
Expand Down Expand Up @@ -6412,6 +6417,8 @@ enum PostsOrderBy {
BODY_DESC
COMPTYPES_ASC
COMPTYPES_DESC
COMPUTED_WITH_OPTIONAL_ARG_ASC
COMPUTED_WITH_OPTIONAL_ARG_DESC
ENUMS_ASC
ENUMS_DESC
HEADLINE_ASC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2313,6 +2313,8 @@ type Post implements Node {
offset: Int
): PostComputedIntervalSetConnection!
computedTextArray: [String]
computedWithOptionalArg(i: Int): Int
computedWithRequiredArg(i: Int!): Int
enums: [AnEnum]
headlineTrimmed(length: Int, omission: String): String
headlineTrimmedNoDefaults(length: Int, omission: String): String
Expand Down Expand Up @@ -2358,6 +2360,9 @@ input PostCondition {
\\"\\"\\"Checks for equality with the object’s \`comptypes\` field.\\"\\"\\"
comptypes: [ComptypeInput]
\\"\\"\\"Checks for equality with the object’s \`computedWithOptionalArg\` field.\\"\\"\\"
computedWithOptionalArg: Int
\\"\\"\\"Checks for equality with the object’s \`enums\` field.\\"\\"\\"
enums: [AnEnum]
Expand Down Expand Up @@ -2442,6 +2447,8 @@ enum PostsOrderBy {
BODY_DESC
COMPTYPES_ASC
COMPTYPES_DESC
COMPUTED_WITH_OPTIONAL_ARG_ASC
COMPUTED_WITH_OPTIONAL_ARG_DESC
ENUMS_ASC
ENUMS_DESC
ID_ASC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7528,6 +7528,8 @@ type Post implements Node {
offset: Int
): PostComputedIntervalSetConnection!
computedTextArray: [String]
computedWithOptionalArg(i: Int): Int
computedWithRequiredArg(i: Int!): Int
enums: [AnEnum]
headline: String!
headlineTrimmed(length: Int, omission: String): String
Expand Down Expand Up @@ -7638,6 +7640,9 @@ input PostCondition {
\\"\\"\\"Checks for equality with the object’s \`comptypes\` field.\\"\\"\\"
comptypes: [ComptypeInput]
\\"\\"\\"Checks for equality with the object’s \`computedWithOptionalArg\` field.\\"\\"\\"
computedWithOptionalArg: Int
\\"\\"\\"Checks for equality with the object’s \`enums\` field.\\"\\"\\"
enums: [AnEnum]
Expand Down Expand Up @@ -7727,6 +7732,8 @@ enum PostsOrderBy {
BODY_DESC
COMPTYPES_ASC
COMPTYPES_DESC
COMPUTED_WITH_OPTIONAL_ARG_ASC
COMPUTED_WITH_OPTIONAL_ARG_DESC
ENUMS_ASC
ENUMS_DESC
HEADLINE_ASC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6256,6 +6256,8 @@ type Post implements Node {
after: Cursor
): PostComputedIntervalSetConnection!
computedTextArray: [String]
computedWithOptionalArg(i: Int): Int
computedWithRequiredArg(i: Int!): Int
headlineTrimmed(length: Int, omission: String): String
headlineTrimmedNoDefaults(length: Int, omission: String): String
headlineTrimmedStrict(length: Int, omission: String): String
Expand Down Expand Up @@ -6302,6 +6304,9 @@ input PostCondition {
\\"\\"\\"Checks for equality with the object’s \`comptypes\` field.\\"\\"\\"
comptypes: [ComptypeInput]
\\"\\"\\"Checks for equality with the object’s \`computedWithOptionalArg\` field.\\"\\"\\"
computedWithOptionalArg: Int
}
\\"\\"\\"An input for mutations affecting \`Post\`\\"\\"\\"
Expand Down Expand Up @@ -6390,6 +6395,8 @@ enum PostsOrderBy {
ENUMS_DESC
COMPTYPES_ASC
COMPTYPES_DESC
COMPUTED_WITH_OPTIONAL_ARG_ASC
COMPUTED_WITH_OPTIONAL_ARG_DESC
PRIMARY_KEY_ASC
PRIMARY_KEY_DESC
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5599,6 +5599,8 @@ type Post {
offset: Int
): PostComputedIntervalSetConnection!
computedTextArray: [String]
computedWithOptionalArg(i: Int): Int
computedWithRequiredArg(i: Int!): Int
enums: [AnEnum]
headline: String!
headlineTrimmed(length: Int, omission: String): String
Expand Down Expand Up @@ -5704,6 +5706,9 @@ input PostCondition {
\\"\\"\\"Checks for equality with the object’s \`comptypes\` field.\\"\\"\\"
comptypes: [ComptypeInput]
\\"\\"\\"Checks for equality with the object’s \`computedWithOptionalArg\` field.\\"\\"\\"
computedWithOptionalArg: Int
\\"\\"\\"Checks for equality with the object’s \`enums\` field.\\"\\"\\"
enums: [AnEnum]
Expand Down Expand Up @@ -5793,6 +5798,8 @@ enum PostsOrderBy {
BODY_DESC
COMPTYPES_ASC
COMPTYPES_DESC
COMPUTED_WITH_OPTIONAL_ARG_ASC
COMPUTED_WITH_OPTIONAL_ARG_DESC
ENUMS_ASC
ENUMS_DESC
HEADLINE_ASC
Expand Down
4 changes: 4 additions & 0 deletions packages/postgraphile-core/__tests__/kitchen-sink-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ create function a.post_computed_compound_type_array(post a.post, object c.compou
create function a.post_computed_text_array(post a.post) returns text[] as $$ select ARRAY['str1','str2','str3']; $$ language sql stable;
create function a.post_computed_interval_array(post a.post) returns interval[] as $$ select ARRAY[interval '12 seconds', interval '3 hours', interval '34567 seconds']; $$ language sql stable;
create function a.post_computed_interval_set(post a.post) returns setof interval as $$ begin return next interval '12 seconds'; return next interval '3 hours'; return next interval '34567 seconds'; end; $$ language plpgsql stable;
create function a.post_computed_with_required_arg(post a.post, i int) returns int as $$ select 1; $$ language sql stable strict;
comment on function a.post_computed_with_required_arg(post a.post, i int) is E'@sortable\n@filterable';
create function a.post_computed_with_optional_arg(post a.post, i int = 1) returns int as $$ select 1; $$ language sql stable strict;
comment on function a.post_computed_with_optional_arg(post a.post, i int) is E'@sortable\n@filterable';

-- Procs -> custom mutations
create function a.mutation_compound_type_array(object c.compound_type) returns c.compound_type[] as $$ select ARRAY[object, (null, null, null, null, null, null, null, null)::c.compound_type, (object.a + 1, object.b, object.c, object.d, object.e, object.f, object.g, object.foo_bar)::c.compound_type]; $$ language sql volatile;
Expand Down

0 comments on commit 2335d6e

Please sign in to comment.