-
Notifications
You must be signed in to change notification settings - Fork 529
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
Multiple GraphQL Backends #387
Comments
So I've started to put together a GraphQL resolver, but I'm struggling to reconstruct the query in the resolver to forward it on. Is there a simple way to do this with the context? |
Hey! There isn't really any built in feature for this yet, nor are there any "client" type facilities in Absinthe to easily reconstruct queries. |
Apollo development just released a very interesting article on GraphQL stitching. It's mainly built on top of their graphql-tools library. Maybe it can serve as reference for a possible implementation here? |
@polmiro I have a rudimentary version of this working, using Tesla as a GraphQL client. At the moment, as @benwilson512 as said, there's no way to reconstruct the query - so I'm just hard-coding the query to request all values. As I said, rudimentary 😄 defmodule Absinthe.ProxyResolver do
use Tesla
adapter :hackney
def user_from_identifier(identifier, _context) do
user = request(method: :get, url: "https://user-service:5050/graphql", body: ~s/
{ user(identifier: identifier) {
forename, surname, email, password_hash
}
}
/)
|> Map.get(:body)
|> Poison.decode!([keys: :atoms])
{:ok, user.data.user}
end
end |
@benwilson512 do you think this "Schema Stiching" capability is something Absinthe will be able to do? We'd love to see this feature, an would like to help in any way possible to make it happen :) |
This should be a lot easier after schema definition changes slated for 1.5. We’ll be switching gears to that after 1.4 hits stable. |
Awesome! |
@bruce Is there a place to see the planned changes for schema definitions? |
@zimt28 the planned changes are first and foremost internal. We expect to avoid any breaking changes, all schemas that work today should continue to work. These changes ought to enable a variety of features however, and fix some bugs along the way. https://github.com/absinthe-graphql/absinthe/milestone/7 tracks the issues associated with the change. |
@rawkode did you ever enhance your resolver? Or is it still simply requesting all values? |
@axelson I'm still using that as is, there's no way to get the query at that stage. I started using Apollo Server, which supports schema stiching, as the API gateway and I am phasing our Absinthe at that layer |
@benwilson512 Given that 1.5 seems to be mostly finished, I was wondering if you might have more information on how difficult schema stitching (or something like it) would be to implement in 1.5? |
@rawkode could you tell us how was your experience using Apollo Server directly? |
Hi, my team at New Relic has schema stitching implemented on top of Absinthe, and I intend to open-source that in the coming months It's not at all trivial, but we have most of the edge cases worked out |
That awesome @binaryseed, if you need some beta testing, at Valiot we use Absinthe for our microservices but an Apollo schema stitcher, we would love to help you and your team. |
@binaryseed any update on the open sourcing? |
Just wanted to note that Apollo deprecated their stitching solution, in favor of Apollo Federation. While stitching was compatible with Absinthe backends, it seems like Federation is not, because they require the 'minion' services to expose a different kind of schema. Interested to see how that fits into this discussion and Absinthe. |
I was wrong: these fancy new Sounds compatible, and also sounds like a thing that could live outside of the main Absinthe repo. Edit +10 hours: I was wrong again... seems like the |
@sebsel did you get anywhere with the federation? |
@JakeBeresford No, I did give it up after writing that above reply. We just use stitching and wrote the stitching service in NodeJS. Federation requires a property on your schema that returns the SDL ( |
Also, this is needed, as I mentioned in the earlier post: #766 Maybe Federation should have it's own issue, as it is quite distinct from what the OP asks for. |
@sebsel Great article on Stitching vs Federation! Any updates on getting the Federation setup to work in Absinthe? Would love to be able to use this for a large microservices project my team is getting ready to start on. |
Should we create a new issue for |
Official Apollo Federation Spec Any updates on this? I'm currently working on Apollo Federation support in Absinthe and the main blockers I have at the moment are:
QUERY DIRECTIVES {
getUser(id: 1) {
id
name @skip(if: true)
}
} This will add SCHEMA DIRECTIVES directive :key do
arg :fields, list_of(:_FieldSet)
on [:object, :interface]
expand fn
_, node ->
Blueprint.put_flag(node, :fields, __MODULE__)
end
end
object :directive_tester, directives: ["I WANT TO APPLY KEY DIRECTIVE WITH ARGS HERE"] do
field :id, :string
field :_resolve_reference, :directive_tester do # should be __resolve_reference with double underscore
resolve(fn _, _, _ ->
{:ok, %{ id: 1 }}
end)
end
end It seems that A built-in example of this is the IMPORTANCE Any guidance on this would be highly appreciated. I have PLENTY of free time right now and would love to learn more about Absinthe and contribute any way I can, including documenting this process. |
From what I can tell, Apollo Federation relies on some behavior that "works around" the GraphQL spec itself... That's why it requires the API to expose the I think it'd be interesting to see Federation support as a library separate from Absinthe itself... A library could make modifications the various pipelines inside Absinthe to change the behavior as desired, like the |
@binaryseed thanks for the prompt reply. I'll look deeper into the exposed SDL, I appreciate the feedback there. My plan is for this to be a separate library without any need to change Absinthe. I'm hopeful that will be possible due to the various extension points available (plugins, middleware, phases etc). |
What kind of work needs to be done to support federation? Either with Apollo in front, or providing a similar functionality without it. Is there currently any way to get this working at all? |
Any updates on this problem? I feel like this is the main deal-breaker for adopting Elixir and Absinthe for most people. |
I've posted this in the various Issues but perhaps not this one... We did open source an example schema stitching application: https://github.com/newrelic/absinthe-schema-stitching-example Building this kind of support into absinthe core is unlikely, but with the flexibility of absinthe as-is, it's possible to accomplish. |
Closing since this kind of feature won't be built into absinthe core. We'd be excited to see what folks in the community are doing in this space! |
Hi,
I have a micro-service architecture, because that's all we do now 😭, and I was hoping to run a master/minion configuration of Absinthe.
What do I mean by that?
Master - API Gateway that handles authentication and passes requests to one or more minions for a response
Minion - Exposes a small GraphQL subset
At the moment, I'm starting to write resolvers that go and speak to other Absinthe servers, but I'm hoping Absinthe will provide a more idiomatic way of providing this.
NB: Apollo are working on exactly this and referring to it as "Schema Stiching": ardatan/graphql-tools#382
The text was updated successfully, but these errors were encountered: