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

Simplify syntax for selecting fields with raw query #26

Open
IlyaSemenov opened this issue Jul 25, 2023 · 0 comments
Open

Simplify syntax for selecting fields with raw query #26

IlyaSemenov opened this issue Jul 25, 2023 · 0 comments

Comments

@IlyaSemenov
Copy link
Owner

Currently, selecting a custom field with raw sql looks like this:

r.table(
      db.post,
      {
        fields: {
          preview: (q) =>
            q.select({ preview: q.sql<string>`substr(text,1,100)` }),

This is too wordy, and, it breaks when a field is requested with an alias:

posts {
  my_preview: preview  # will not work
}

The syntax should rather be:

r.table(
      db.post,
      {
        fields: {
          preview: (q) => q.sql<string>`substr(text,1,100)`

with orchid-graphql wrapping the field select.

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

No branches or pull requests

1 participant