Open
Description
I'm submitting a ...
- bug report
- feature request
- [x ] question
PostGraphile version: [email protected]
pg-order-by-related version: @graphile-contrib/[email protected]
Minimal SQL file that can be loaded into a clean database:
create table foo (
id integer primary key,
foo_name text not null
);
create table bar (
id integer primary key,
bar_name text not null,
foo_id integer references foo (id)
);
insert into foo (id, foo_name) values
(1, 'a'),
(2, 'b'),
(3, 'c'),
(4, 'd');
insert into bar (id, bar_name, foo_id) values
(1, 'one', 1),
(2, 'two', 2),
(3, 'three', 3),
(4, 'four', 4);
CREATE INDEX ON bar(foo_id);
CREATE FUNCTION get_bar_custom_query() RETURNS SETOF bar AS $$
SELECT * FROM bar
$$ LANGUAGE sql STABLE;
COMMENT ON FUNCTION get_bar_custom_query() IS E'@sortable';
Query:
query {
first: getBarCustomQuery(orderBy: FOO_BY_FOO_ID__ID_ASC, first: 2) {
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
edges {
node {
id
barName
foo {
fooName
id
}
}
}
}
second: getBarCustomQuery(orderBy: FOO_BY_FOO_ID__ID_ASC, first: 2, after: "WyJmb29fYnlfZm9vX2lkX19pZF9hc2MiLDJd") {
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
edges {
node {
id
barName
foo {
fooName
id
}
}
}
}
}
CLI command:
postgraphile \
--dynamic-json \
--no-setof-functions-contain-nulls \
--no-ignore-rbac \
--no-ignore-indexes \
--show-error-stack=json \
--extended-errors hint,detail,errcode \
--append-plugins @graphile-contrib/pg-simplify-inflector,@graphile-contrib/pg-order-by-related \
--enhance-graphiql \
--allow-explain \
--enable-query-batching \
--legacy-relations omit \
--connection postgres://user:password@localhost:5432/my_db \
--schema public
Current behavior:
Error: "The order supplied is not unique, so before/after cursors cannot be used. Please ensure the supplied order includes all the columns from the primary key or a unique constraint."
Expected behavior:
Result will be ordered by the column from the related table.
Metadata
Metadata
Assignees
Labels
No labels
Activity