You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this example you have a Core module that contains the type User that have linked account to different platforms.
Is there any best practices on how to extend the loaders inside the platform resolver depending on what modules being registered? I would like to keep all platform related code in separate modules but I don't really know how to write that code. I've already have some code that is working but it more or less an "hack" and it's not aware which modules being registered by the application. I tried to use middleware but I didn't get it to work and my understanding is that middleware are not being merged/concatinated only picking the first module that defines a specific path? If they were merged it would be possible to achieve what I'm looking for. Maybe I've missed something or isn't this supported at the moment?
This is a very simple example and only two platforms but a more advanced example might involve hundreds of platforms.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In this example you have a Core module that contains the type
User
that have linked account to different platforms.Is there any best practices on how to extend the loaders inside the
platform
resolver depending on what modules being registered? I would like to keep all platform related code in separate modules but I don't really know how to write that code. I've already have some code that is working but it more or less an "hack" and it's not aware which modules being registered by the application. I tried to use middleware but I didn't get it to work and my understanding is that middleware are not being merged/concatinated only picking the first module that defines a specific path? If they were merged it would be possible to achieve what I'm looking for. Maybe I've missed something or isn't this supported at the moment?This is a very simple example and only two platforms but a more advanced example might involve hundreds of platforms.
Here are a simple codesandbox with my preferred way (not working because middlewares not being merged):
https://codesandbox.io/s/graphql-module-feature-request-middlewares-merge-kuq4uf?file=/index.js
Here are the playground
Dynamic fetch Facebook:
https://kuq4uf.sse.codesandbox.io/?query=query+getUserFacebook+%7B%0A++user%28id%3A+1%29+%7B%0A++++platform%28name%3A+FACEBOOK%29+%7B%0A++++++__typename%0A++++++username%0A++++%7D%0A++%7D%0A%7D
Dynamic fetch Google:
https://kuq4uf.sse.codesandbox.io/?query=query+getUserGoogle+%7B%0A++user%28id%3A+1%29+%7B%0A++++platform%28name%3A+GOOGLE%29+%7B%0A++++++__typename%0A++++++username%0A++++%7D%0A++%7D%0A%7D
I would like to be able to write queries like this:
Beta Was this translation helpful? Give feedback.
All reactions