Giter VIP home page Giter VIP logo

Comments (11)

a-type avatar a-type commented on May 24, 2024 1

Great, I think that's enough info for me to get started on a PR.

from prisma-binding.

schickling avatar schickling commented on May 24, 2024

Great point! This should definitely be improved. The caching mechanism is intended however it should cache based on a schema level (so instead of a single cache variable there should be a cache map).

from prisma-binding.

a-type avatar a-type commented on May 24, 2024

Newcomer to the project; Git history shows graphql-schema-cache previously used. Was there a reason for dropping it?

from prisma-binding.

schickling avatar schickling commented on May 24, 2024

Yes this was based on a different β€žarchitectureβ€œ and is now no longer needed. It refers to another kind of cache than this issue describes.

from prisma-binding.

pollard93 avatar pollard93 commented on May 24, 2024

Another newcomer! I have another use case: i'm building a multi tenant system of which I am deploying multiple databases with identical schemas. E.g service-1@dev and service-2@dev.

I want to then switch the endpoint when creating a new Prisma instance on each request. E.g endpoint/service-1/dev and endpoint/service-2/dev.

However due to getCachedRemoteSchema using the typeDefs as the key, it's impossible to switch endpoints on the fly if the schemas are identical.

I've got it working by using the endpoint as the key. Is this a suitable solution for my use case?

from prisma-binding.

Errorname avatar Errorname commented on May 24, 2024

Hi there!
I have the same issue as @pollard93 , I can't switch between multiple endpoints having the same schema.

But I've found a solution which doesn't require me to fork this repo until a better solution is found.

I currently am doing a workaround by importing the typeDefs from the file myself and then appending a comment with the service and stage names. This makes the cache think the typedefs are different.

from prisma-binding.

pollard93 avatar pollard93 commented on May 24, 2024

@Errorname Nice workaround I'm now doing the same, thanks.

from prisma-binding.

maticzav avatar maticzav commented on May 24, 2024

Hey πŸ‘‹, I believe this issue has been resolved in most recent versions of prisma-binding. Taking @schickling's comment as a basis, I believe new implementation constructs a remote schema based on provided typeDefs instead of blindly saving a global default.

More about this can be found in the cache.ts file of prisma-binding; I'll include the link below.

https://github.com/prisma/prisma-binding/blob/master/src/cache.ts

from prisma-binding.

Errorname avatar Errorname commented on May 24, 2024

Hey @maticzav !
Well, @pollard93 and I still have an issue with the current implementation. Here is our issue:

We both have a multi tenant system in which we created multiple services having the exact same schema (and therefore same provided typeDefs). Then, using prisma-binding, we try to register some (at least two) of our identical services. But, because they have the same typeDefs, the cache only sends requests to the first registered service!

In order to make a multi-tenant application with prisma-binding, we have to bypass the cache using the following trick:
For each of our services, we manually import the typeDefs file ourselves, and append a comment with the service and stage name. The cache is now fooled thinking they are different typeDefs and allow us to query independently our services.

I hope I explained why the cache is still a issue, at least for our use-case.

from prisma-binding.

Errorname avatar Errorname commented on May 24, 2024

I think a potential solution for our issue would be to cache based on the endpoint instead of the typeDefs

from prisma-binding.

schickling avatar schickling commented on May 24, 2024

πŸŽ‰ This issue has been resolved in version 2.2.3 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€

from prisma-binding.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.