Closed terion-name closed 5 years ago
What you could currently do if you manage your Prisma backends outside of your Graphl Server project, is use prisma-bindings
and add the Prisma backends as regular endpoints (so without the prisma extension in the config). That way, they would behave like any other endpoint.
It would allow you to add two Prisma bindings to your context. Is your example, you are adding two endpoints to a single binding, but I don't see any benefit over using two bindings.
I have a use case that involves multiple Prisma APIs to bind against. After trying to create two separate Prisma
objects in context, I noticed that they both ended up pointing to the same schema and endpoint. If I understand the conversation correctly so far, that means @kbrandwijk 's suggestion will not behave as expected.
The problem appears to be rooted in the global variable for remoteSchema
https://github.com/graphcool/prisma-binding/blob/2117ddffdad990867616505ef80f618e4628a21d/src/Prisma.ts#L16. If I construct a Prisma
pointed at a particular schema, then a second one, both instances will use the first schema provided due to the check on line 59 https://github.com/graphcool/prisma-binding/blob/2117ddffdad990867616505ef80f618e4628a21d/src/Prisma.ts#L59.
I haven't used TypeScript before, but I could try to put in a patch. Changes were introduced in https://github.com/graphcool/prisma-binding/commit/67612e9505a97032489238a7db55fbf20b47f9e0; any fix would probably benefit from understanding why the remote schema caching was changed.
@a-type That is a very good point, thank you for bringing this up. I have created https://github.com/graphcool/prisma-binding/issues/81 for this.
@a-type would you be open creating a PR for this (see #81)?
@schickling Sure, I'll look into doing that soon. Be advised that I've never written Typescript before, but hopefully this is a fairly trivial change.
Fixed with #81
One great feature with graphql is that one can combine multiple apis in one, with schema stitching or weaver schemas. The same applies here: one could have multiple underlying prisma services (with different contexts and/or different types of db) and it would be great to in single binder, something like this:
This comes from a real-world necessity and I thing some other people would also benefit from this