Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(utils): @pgQuery.source can be function #555

Merged
merged 4 commits into from
Nov 7, 2019

Conversation

benjie
Copy link
Member

@benjie benjie commented Nov 5, 2019

E.g. if we need to enable a subquery that references the parent query builder's alias.

foo: ItemConnection @pgQuery(
  source: ${embed(
    ({ parentQueryBuilder }) => sql.fragment`(
  select items.*
  from mindtree_public.items
  inner join lateral unnest(${parentQueryBuilder.getTableAlias()}."starredTopicIds") with ordinality as star(id, idx) on (star.id = items.id)
  where items.type = 'TOPIC'
  order by idx asc
)`
  )}
  withQueryBuilder: ${...}
)

NOTE: we should also allow blocking the default value for the orderBy argument which is added automatically (I think?) - e.g. in this case it's important the default order is NATURAL since the result set is already ordered (but the order value does not leak).

@benjie benjie marked this pull request as ready for review November 7, 2019 09:53
@benjie
Copy link
Member Author

benjie commented Nov 7, 2019

👍 Ready for merge.

@benjie benjie merged commit 907c8e6 into master Nov 7, 2019
@benjie benjie deleted the utils-pgquery-source-callback branch November 7, 2019 10:20
@benjie benjie restored the utils-pgquery-source-callback branch November 7, 2019 10:20
@benjie benjie deleted the utils-pgquery-source-callback branch November 7, 2019 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant