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

OrderBy not working #237

Open
aaronbach opened this issue Sep 10, 2018 · 1 comment
Open

OrderBy not working #237

aaronbach opened this issue Sep 10, 2018 · 1 comment

Comments

@aaronbach
Copy link

Is there a possibility, to use orderBy?

I played around with prisma-binding and an prisma-yoga, which I have created with the prisma-yoga-boilerplate. I have added a custom resolver wich looks like this:

    // ...
    async myNotifications (parent, args, ctx: Context, info) {
      const userId = getUserId(ctx);

      const query = `
        query myNotificationStatuses ($userId: ID!) {
          notificationStatuses (
            orderBy: createdAt_DESC
            where: {
              user: {
                id: $userId
              }
            }
          ) ${info}
        }
      `;

      return ctx.db.request(query, { userId: userId });
     // Second Scenario which also dosn't work
      /*ctx.db.query.notificationStatuses({
        orderBy: 'createdAt_DESC',
        where: {
          user: {
            id: userId
          },
          archived: false
        }
      }, info);*/
    },
    // ...

It seems that there is no possibility, that I can order the results. When I look in the console-output from yoga there I can not see that orderBy is passed through to prisma.

When I use the playground and use the following query, and set my userId in the variables-section, everything is working fine:

query getMyNotificationStatuses ($userId: ID!) {
  notificationStatuses (
    where: {
      user: {
        id: $userId
      }
    }
    orderBy: createdAt_DESC
  ) {
    id
     ...
    createdAt
    updatedAt
  }
}

Thanks for your help

@maticzav
Copy link
Collaborator

Hey @aaronbach 👋,

Could you verify that this is still an issue with the latest version of prisma-binding?

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

2 participants