some sort of “I plug it in and it’s exposed throug...
# orm-help
v
some sort of “I plug it in and it’s exposed through my graphql server without requiring me to write wrapper resolvers for each of the things I want to expose”
f
I think you can use
forwardTo
function from
prisma-binding
to redirect resolvers
v
Ok, that’s useful enough, but it still means that if I have 100 queries and mutations, I have to do that for each of them…
don’t get me wrong, I totally understand why it’s done that way, but it’d be cool to have some sort of a shortcut.
f
Yep. Otherwise, if you don’t need auth (rare case), you can connect to Prisma directly from the browser.
h
You can import schema and then generated resolvers 🙂
v
And that is the crux of the matter: placing auth on top of it.
Are there generated resolvers to import?
v
I see
Ever thought to provide that through Prisma itself? As it generates a schema that one pulls down, and it’s also now generating prisma-client, could be an idea to generate the resolvers too, so one can import them “as is”, and then just stick the auth on top of the whole thing via
graphql-shield
? 🙂
Ok, this might not be ideal, so looking for feedbacks (bear in mind the following code is rough):
Copy code
const { forwardTo } = require("prisma-binding");
const { buildSchema } = require("graphql");

const schemaFile = `${__dirname}/schema/prisma.graphql`;
const schema = require("fs")
  .readFileSync(schemaFile)
  .toString();
const s = buildSchema(schema);
const queries = Object.keys(s.getQueryType().getFields());
const mutations = Object.keys(s.getMutationType().getFields());
const Query = {};
queries.forEach(element => {
  Query[element] = forwardTo("prisma");
});
const Mutation = {};
mutations.forEach(element => {
  Mutation[element] = forwardTo("prisma");
});

const resolvers = {
  Query,
  Mutation,
};
Anyone got a feedback about the above?
u
So does prisma-client introduce any new approaches for query forwarding?