Skip to content
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

Gateway should offer configuration point for introspection query #2891

Closed
JacksonKearl opened this issue Jun 20, 2019 · 8 comments
Closed

Gateway should offer configuration point for introspection query #2891

JacksonKearl opened this issue Jun 20, 2019 · 8 comments
Assignees

Comments

@JacksonKearl
Copy link

Gateways currently offer a configuration point for buildService -> willSendRequest, which allows setting headers on normal federated requests to their services, but they offer no configuration hook for sending the initial query GetServiceDefinition { _service { sdl } } request.

https://spectrum.chat/apollo/apollo-federation/sending-authorization-header-on-gateway-introspection-query~e8c3c16a-07b7-464a-97f5-13f577591bb9

@JacksonKearl
Copy link
Author

Made a quick demo implementation, we can discuss API in this thread.

@ElliotChong
Copy link

I just ran into this issue today (my service requires a particular header), FWIW it would be nice to be able to manipulate headers on a per-service basis rather than just globally. Perhaps as a headers prop that can be included alongside name and url?

@brandonpapworth
Copy link

This would be quite helpful, but I also see it as useful for us to possibly configure the actual method used to communicate with the service. One might want to use lambda.invoke as opposed to fetch, and all we would need is to provide a function that implements a similar API.

I have patched the Apollo Gateway in my own codebase to facilitate my desire for leveraging lambda.invoke (why add an API Gateway layer if I don't need it? 😄 ) with some of the services, ensuring to construct the context object to be properly accepted by the apollo-server-lambda handler.

@jaknor
Copy link

jaknor commented Jul 17, 2019

Hey @JacksonKearl thanks for making those changes. Is there any documentation for this yet? Also, is my understanding correct that you would be sending the same headers for all introspection queries?

In our use case we would want to send different headers to each service, or in some cases, the same headers but different values. Is there a way of doing that?

@JacksonKearl
Copy link
Author

Hey @jaknor, no docs yet. And still open to changes on the interface, what would you like to be able to do? For instance, would introspectionHeaders: HeadersInit | (url: string) => HeadersInit work?

@jaknor
Copy link

jaknor commented Jul 17, 2019

To confirm, would the headers then only be applied for the specified url? That should work for this particular use case.

Thinking a little more about it we have also looked at using IAM authentication for our AWS API gateway. this however requires that you sign the request which in turn requires access to the request uri, body, headers etc. In schema stitching we were able to achieve this using a custom fetch method on the HttpLink object. This also had the added benefit that the same HttpLink was used for both introspection and regular requests so we only had to specify our custom logic once.

Without having looked too much into the code it appears that the willSendRequest method on a RemoteGraphQLDataSource would be a good place for the logic, however, this does not appear to be used for introspection. Is there a reason for this? At the moment I can't think of a reason why I would want my introspection request to be treated differently from other requests but I am probably missing some context.

If we don't want to use the RemoteGraphQLDataSource for the introspection I think it would be good to have a method similar to willSendRequest available for introspection but it would have to be per service.

I am also thinking that the managed federation announced yesterday might solve this as we would not be introspecting to get the schema, we would be querying engine, however I am not convinced I would want to use this approach during development but rather just introspect to keep things simple. I need to look into how it all works a bit more before making my mind up on that one though.

@mcohen75
Copy link
Contributor

mcohen75 commented Aug 1, 2019

I also have need to enhance the request beyond just modifying headers. In my case I need to add request parameters to the URL for some federated services.

I also think that RemoteGraphQLDataSource seems like a nice way to accomplish request enhancement. I assumed this was already the case and was surprised that introspection queries were special in this regard.

I just submitted a PR that uses RemoteGraphQLDataSource when issuing introspection queries.

@trevor-scheer
Copy link
Member

Closed by #3120

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants