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

federation: node-fetch in @apollo/gateway doesn't support unix: urls #333

Closed
lennyburdette opened this issue Jun 12, 2019 · 4 comments
Closed

Comments

@lennyburdette
Copy link
Contributor

Version: @apollo/gateway@0.6.6

Description:
We use an envoy sidecar process to manage service-to-service routing. All requests go to the same unix socket and we add headers to tell envoy which service cluster to route to.

const gateway = new ApolloGateway({
  serviceList: [
    { name: 'service-a', url: `unix:/path/to/envoy.sock:/graphql` },
    { name: 'service-b', url: `unix:/path/to/envoy.sock:/graphql` },
  ],
  buildService({ name, url }) {
    return new RemoteGraphQLDataSource({
      url,
      willSendRequest({ request }: any) {
        request.http.headers.set('Host', `${name}.specialenvoyheader`);
      }
    });
  }
});

Currently, this cannot work because getServiceDefinitionsFromRemoteEndpoint in @apollo/gateway uses node-fetch, which throws this error: Only HTTP(S) protocols are supported.

We use unix sockets because we can chown the socket and restrict access to it, unlike a tcp port. If we used TCP we'd have to also use TLS, which is overhead and complexity we'd like to avoid.

Adding support for unix sockets in node-fetch is marked as "wontfix".

I would suggest the got library, which has the same API, but it has 58 transitive dependencies compared to node-fetch's zero. 😬

@lennyburdette lennyburdette changed the title federation: node-fetch in @apollo/gateway don't support unix: urls federation: node-fetch in @apollo/gateway doesn't support unix: urls Jun 12, 2019
@lennyburdette
Copy link
Contributor Author

I might be able to switch to TLS over TCP, but I'll need to be able to pass agent to node-fetch so I can use our self-signed certs.

@jbaxleyiii
Copy link
Contributor

Hey @lennyburdette! We are working on a way to provide the service definitions files instead of having to the do the fetch at startup. That plus providing a custom datasource should be enough for y'all yes?

@lennyburdette
Copy link
Contributor Author

@jbaxleyiii That would probably do it! I'm blocked on building out a proof-of-concept for now, but it's good to know there's an alternative in the works.

If fetching the _service.sdl field lives on for certain use cases, it might be worth adding an agent: http.Agent option to the ApolloGateway constructor.

@abernix abernix transferred this issue from apollographql/apollo-server Jan 15, 2021
@lennyburdette
Copy link
Contributor Author

closing this as super old! i'm pretty sure i figured it out, and we use make-fetch-happen now anyway.

@lennyburdette lennyburdette closed this as not planned Won't fix, can't repro, duplicate, stale Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants