Replies: 8 comments 15 replies
-
If you are trying this out (or avoiding it because it doesn't support your use case). I'd love to hear how you are using it, and how you are structuring your input types. Specifically I'd love to know what patterns you want/expect for filters (This initial version is closely modeled on prisma API, but would love to see other ways of doing this). Other things I'd be currious to know about are patterns/requests/requirements for non-list fields, or anything else thats missing. Input types for creating/updating/deleting are obviously not supported yet, but if you have specific examples of patterns that you like for this, that could also be valuable to share here. |
Beta Was this translation helpful? Give feedback.
-
I've seen this used with Would it be possible for |
Beta Was this translation helpful? Give feedback.
-
How would you prevent builder.queryField('companies', t =>
t.prismaField({
type: ['Company'],
args: prismaArgs.Company,
resolve: async(query, root, args, { prisma }) =>
prisma.company.findMany({
...query,
...args,
}),
}),
)
|
Beta Was this translation helpful? Give feedback.
-
Thanks @hayes for your incredible love and passion for your library and the community generally. If I can help make this a reality, please let me know. I'm an app developer that's always scared of libraries and doesn't feel smart enough to help but I need to get over my irrational fear and contribute back. I've been in the GraphQL space since 2016 and thought the original nexus-prisma plugin was the high water mark for auto gen CRUD. For example...
See more at: https://www.prisma.io/blog/using-graphql-nexus-with-a-database-pmyl3660ncst The big pain points for autogen and pothos now there I think the helpers you've already done get 99% of the way there for queries. Here's an example where I converted Nexus + Nexus-Prisma to Pothos
That's a pretty straight forward solution without too much pain. Mutations are still problematic though with a lack of
The only issues I've run into is duplication of types, e.g. Vendor will have a VendorOrderBy for the query and mutation, and exposing the enums. Since the same Enum will be in multiple objects, I expose them up front..
|
Beta Was this translation helpful? Give feedback.
-
Some updates for anyone following this discussion: I spent some time the last couple days implementing support for mutation types in the prisma-utils plugin. It doesn't cover everything yet, but it should be a great start for anyone trying to quickly build crud apps with pothos and prisma. What's being added
This change has not been merged, but a preview release is available, and I would really love any feedback. If you are interested in this topic, and have some time, please try it out: #703 I haven't gotten much actionable feedback outside of asking for support for mutations, so hopefully this will unblock some people from giving it a try |
Beta Was this translation helpful? Give feedback.
-
Coming from Prisma1 it generated every possible thing in the schema that you could think of (types, create inputs, createMany inputs, update inputs, updateMany inputs, where inputs (including AND/OR/NOT, in, not_in, lt, lte, gt, gte, contains, not_contains, starts_with, not_starts_with), orderBy inputs, subscription payloads, subscription previous values, AND/OR/NOT, connections, edges, nested/related table concurrent-create inputs, createMany inputs) and then you could pick and choose or copy/paste/modify whatever you needed from it or choose to leave it all in the schema. I simply chose the ones I needed and used those and it saved me loads of time. My old prisma.graphql autogenerated file is 10500 lines long so I have quite a few inputs to create. My project has 27 tables, 105 queries and 11 enums, that's a lot to convert manually! Maybe there's some inspiration to be found for you in looking at some Prisma1 generator source code, because having all that info there is VERY helpful to understand prisma and its power, and to take advantage of it. I noticed in the readme it says "the goal is not to generate all input types automatically" but having a generated file with all possible types was very valuable to me in the past, so maybe that can be an option in the generator to create an "everything" output file just for reference (but not have everything in the actual schema except the bits and pieces one needs for their schema). As soon as I get a chance to play with this I'll provide feedback. Thanks for so much work on a very cool package, I'm quite glad I found Pothos. |
Beta Was this translation helpful? Give feedback.
-
After a long delay, a new version of this plugin was finally published! Check it out https://pothos-graphql.dev/docs/plugins/prisma-utils and let me know what you think! |
Beta Was this translation helpful? Give feedback.
-
Hi @hayes ! Thank you for your effort in making this plugin possible! 🙌 Example code hereexport const MyCreateInput = builder.prismaCreate("MyModel", {
name: "MyCreateInput",
fields: () => ({
myRelationId: "String",
}),
});
t.field({
...
args: {
data: t.arg({ type: [MyCreateInput], required: true }),
},
resolve: async (_p, { data }) => db.myModel.createMany({
data, // this throws typeerror: Property 'myRelationId' is missing in type 'MyCreateInput' but required in type 'MyModelCreateManyInput'
}),
}); Casting doesn't help as it throws the same error. Explicitly specifying this field (via Are there any plans for implementing this? Thanks in advance! 🚀 Versions
|
Beta Was this translation helpful? Give feedback.
-
I just published the initial version of a new plugin to start supporting some use-cases for tighter prisma integration with Pothos.
So far the prisma plugin has been purely focused on defining output types, fields, and relations. This adds a lot of value, but there are a lot of use-cases that require a non-trivial amount of manual work around inputs.
The prisma-utils plugin is meant to start provide helpers to simplify that process.
The initial version is focused on creating input types for filtering and ordering lists of prisma objects.
If you have been looking for ways to simplify the process of creating input types, I would love to get some feedback on this initial version.
Very limited docs are available here: https://github.com/hayes/pothos/tree/main/packages/plugin-prisma-utils
The example at the bottom is meant as an example of the kind of tools that could be created either internally for your app, or published as a community maintained package. The implementation is hopefully simple enough to understand and customize to your own needs.
In the future I would like to add more utils to make those generator scripts even simpler.
Beta Was this translation helpful? Give feedback.
All reactions