Hello everyone, I am trying to pass a model in it'...
# orm-help
r
Hello everyone, I am trying to pass a model in it's full context over to a graphql server and it seems in schema.graphql I have to recreate all the mutations and queries, I'd simply just like to expose that model and all of it's full CRUD to graphql without having to replicate
m
Yes, just do:
Copy code
# import Query.fooBar from "./generated/prisma.graphql"
# import Query.fooBars from "./generated/prisma.graphql"
# import Mutation.updateFooBar from "./generated/prisma.graphql"
# import Mutation.updateManyFooBars from "./generated/prisma.graphql"
# import Mutation.createFooBar from "./generated/prisma.graphql"
...etc
r
ah ok thank you
oh man didn't realize you had to explicitly import each of those, but I guess that's a good thing to have to ensure one doesn't accidentally expose pieces of their database that they weren't intending
m
Then create the corresponding resolvers with all the deferred CRUD
Yeah, like “Oops, I exposed
deleteManyFooBars
r
oh you lost me on that last part sorry
for sure 👍
m
That’s the worst one to expose to your users likely
r
definitely
so what did you mean by this one "Then create the corresponding resolvers with all the deferred CRUD"
m
Create resolvers that look like:
Copy code
fooBars(parent, args, ctx: Context, info) {
    return ctx.db.query.fooBars(args, info);
  },
r
ah ok
m
Or
Copy code
const {forwardTo} = require('prisma-binding');
fooBars: forwardTo('db')
👍 2
r
I'll give this a shot, thank you for providing those details