If I'm generating the `javascript-client`, does it...
# prisma-client
k
If I'm generating the
javascript-client
, does it make sense to import the
typeDefs
from
prisma-client.js
into whatever I'm using to make my graphql server? The Prisma tutorials have you create your own
schema.graphql
file to supply the
typeDefs
, but that seems redundant to rewrite your schema after writing it in the
datamodel.prisma
file.
n
Regarding this, what exactly are you trying to do? Do you want to mirror the entire Prisma GraphQL CRUD API on your application layer? (i.e. in your GraphQL Yoga or Apollo server)
k
The truth is this is just my first crack at doing anything with Prisma, and I was a bit confused why you were generating all these type definitions for me but I wasn't using them.
I was trying to write a particular mutation that kept giving me a type error, but the name of the type was a generated one that I didn't have in my own
schema.graphql
file, and I was like, "Maybe the way I solve this without writing my own schema is to import the typeDefs" 🤔
It's one of those things if I knew what I was doing, all of this would probably feel and seem obvious to me, but I'm learning and trying to follow docs, but finding gaps in translating the ideas in the docs to the little app I'm trying to build. I don't know that the docs are the problem, I'm totally willing to admit the problem might just be me 😝, cause I can't put my finger on what I'd like to see different and I want to respect the work put in.
To be clear, weight this like 99% it's me that's dumb vs. 1% any challenge/problem with the docs. Y'all are doing good work 👍
n
I'm happy to help you with any questions you have! We're aware that the docs have some gaps, especially when it comes to connecting the dots. We're currently in a cleanup phase there, but it's probably going to take a while until everything is properly cleaned up and consolidated.
Just let me know when I can help 🙂
k
Thanks, appreciate it.
One thing you may be able to help me understand, Prisma generates all these types and input types for me, is there a way to import the exact ones I want into my schema.graphql file? I'm particular struggling with creating update mutations, where I'd like to be able to just import the corresponding input data type and where types. Is that what this is for? https://github.com/prisma/graphql-import
n
graphql-import
indeed is a tool that lets you import types from your
prisma.graphql
(which defines the full CRUD API) into your
schema.graphql
(we call this application schema).
If your application schema and the Prisma schema are tightly coupled, it's definitely fine to use
graphql-import
. As a a matter of fact, especially when starting a project this is often what you want. Typically the application schema becomes more specific over time and that's when you start decoupling it from the Prisma schema 🙂
k
Cool, thanks for the info.
b
If you import using graphql-import, how do you provide the default implementation for those resolvers? Is there a progressive way to add custom functionality while falling back by default to prisma crud everywhere else?