Giter Club home page Giter Club logo

Comments (4)

maoosi avatar maoosi commented on May 27, 2024

Ideally, I would like to support both multiple orderBy and orderBy on relations. I’m not yet settled on the best approach.

What you are suggesting could be one solution. A second one could be turning orderBy input into an array, similar to: https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#sort-user-by-multiple-fields---email-and-role

A third solution (not exactly following Prisma syntax) - would be using a similar structure to filters, where you can use the AND: [] syntax for multiple orderBy and directly target a field or a relation:

input PostOrderByInput {
    AND:[PostOrderByInput]
    title: OrderByArg
    author: UserOrderByInput
}

FYI - Early next week, I'll release a new version that introduces pagination and a new where filtering mechanism closer to Prisma (as you suggested in another issue). You can try it via yarn add prisma-appsync@next. Quick overview at: https://github.com/maoosi/prisma-appsync/blob/next/CHANGELOG.md#version-100-beta55

from prisma-appsync.

DregondRahl avatar DregondRahl commented on May 27, 2024

With the code above, it accepts the orderBy in this way
orderBy: {id: DESC, name: DESC}

But converts it to prisma syntax
orderBy: [{ id: DESC }, { name: DESC }];

Which for me looks good because I won't need to nest the orderBy items, however if we can support more similar syntax as prisma and nexus (second option) it will be easier for developers to shift from nexus if they need to deploy with AppSync.

The third option, looks good, but I'm not familiar with that syntax being used anywhere else. Though it would be clear the order at which records will be sorted in.

Regarding the pagination update, I'm just working on a few things so it was easy enough to add while I checked on a few integrations. This package is honestly a life saver!

I added count() also to help with offset pagination

    public async count(model: string, args: RequestProps) {
        await this.runBeforeResolveHook({
            operation: Operations.count,
            model,
            args,
        })

        if (process.env.JEST_WORKER_ID) return args

        // count all records matching the where arguments
        const results = await this.prisma[model].count({
            ...(args.where && { where: args.where }),
            ...(args.skip && { skip: args.skip }),
            ...(args.take && { take: args.take }),
            ...(args.cursor && { cursor: args.cursor }),
            ...(args.distinct && { distinct: args.distinct }),
            ...(args.orderBy && { orderBy: args.orderBy }),
        })

        await this.runAfterResolveHook({ result: results })

        return results
    }

from prisma-appsync.

maoosi avatar maoosi commented on May 27, 2024

Thanks for sharing your thoughts on this! I’ll add both refactoring of orderBy and adding a count query to the roadmap.

Before diving into new features, I will spend some time refactoring the Tests and adding some CI/CD automation. After this is in place, it will make it easier to directly submit pull requests, in case you would like to contribute.

from prisma-appsync.

maoosi avatar maoosi commented on May 27, 2024

Both implemented in 1.0.0-beta.58.2 (see orderBy query filter and count query).

from prisma-appsync.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.