-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue with remote schema #19
Comments
Hey @jeremie-stratumn 👋, Thank you for such a nice feedback. I am having a hard time replicating this. Would you mind sharing a bit more of your code? What's the version of Let me know and I'll help you out! |
Thanks for your reply @maticzav . After digging a bit more it turns out that my issue is related to schema stitching.. I have put an example together here: I wonder if there is a solution for this.. Let me know what you think. Thanks! PS: I took the liberty to rename the issue now that I understand a bit more where it's coming from.. |
@jeremie-stratumn this is perfect! Your code example made things a lot easier to understand. So, let me get right into unravelling the mysteries of your question.
I'll explain these in more detail, but first, I want to make sure we understand all the parameters resolver gets.
Because we've built remarkably numerous tools for making GraphQL server creation easier, it might be hard to see pure GraphQL under all the abstractions these tools create. Let's refocus on our issue; we are modifying the Since there's no way, at least that I know of, which would give you such functionality using You can probably sort the missing pieces out yourself. Do tell me if you still need any help with that. I hope this gives you a better picture of what's going on internally. 🙂 |
Thanks for your response and the clear explanation. It did seem like a long shot to be able to modify the parent of a remote schema.. I have thought of using |
Hey hey! Yes, of course! My bad on this one. The problem is that Do you maybe see how this could be solved differently? It would also be precious if you could explain the actual problem you're having a bit since I suppose the example is only a representation of your issue. |
Some background on this. I have a main yoga server that handles subscriptions (so long lived) and multiple graphql lambdas that handle different business logics. I do schema stitching on the main server. I have implemented an ACL (Access Control) layer that controls when a request comes in that the user is logged in and is authorized to do the action. Ideally I would want this layer to be executed on the main server, via a middleware ( But I am struggling when I have a query that returns a collection of resources that the user has access to. For example:
In this case I would like my ACL to run first on the main server, gather all the book ids the user is authorized to read, and pass that to the lambda either via the What I did is, I moved the ACL for this specific case to the resolver on the lambda itself. I make an explicit call to the ACL first, get a list of ids and the resolve the books. I guess one solution could be to have an optional argument on the
that the middleware could populate, but I don't like that I have to modify the schema to solve a technical limitation of the tools I use. Hope this is more clear now? |
Hey @jeremie-stratumn, thank you for being so patient with my reply. Last two weeks were hectic, and your response was sitting in the leftmost corner of my Chrome all the time. Finally, I get to answer. If I understand you correctly, you would like to use I reread your question, took another perspective, and I had an idea. I love your approach to filtering If I draw a quick diagram of how I understand your idea; const Query = {
books: (parent, args, context, info) => {
return [1,2,3,4,5]
}
}
// Middleware somehow filters [1,2,3,4,5] and delegate somewhere in between [1,2,3], right?
const Book = {
name: (parent, args, context, info) => {
return name
}
}
// Get's executed for each id. I am not sure this could even work, to be honest. As I said, this is only my thinking. If you get an idea of how this could generally work in I hope I helped you somehow with my response. |
Hey. So it's actually the other way around. before running the query, the middleware would filter what I am allowed to read: // middleware: [1,2,3,4,5] => [1,2,3] then: const Query = {
books: (parent, args, context, info) => {
// read [1,2,3] from parent or args
}
} |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
sorry, I think I have some issue, the args to a remote query cannot be editable in the main server.
@maticzav from your words, I think using middleware to update remote query's input is impossible, right ? |
Let me first thank you for this great lib!
I came across a use case where I would like to use a middleware to change the parent argument of a resolver:
But in my resolver the parent is always null... Any reason why we do not allow modifying the parent object for a root query?
Thanks!
The text was updated successfully, but these errors were encountered: