Hello, I’ve followed the instructions to generate a supergraph.graphql file using rover. To do this locally I had to use the --insecure-accept-invalid-certssetting as my dev server has self signed certificates.
When it comes to creating the gateway using the supergraph.graphql file, I get the following error.
graphQLErrors: [
{
message: 'request to https://mysite.localhost/graphql failed, reason: self signed certificate',
extensions: [Object]
}
],
Is there a config option I can pass to ApolloGateway and/or ApolloServer’s constructor when doing local development to avoid the issue with self-signed certificates? I have already tried setting NODE_TLS_REJECT_UNAUTHORIZED=0 in my .env.local but it seems this is ignored.
const supergraphSdl = readFileSync('./supergraph.graphql').toString();
const gateway = new ApolloGateway({
supergraphSdl,
});
const apolloServer = new ApolloServer({
gateway,
});
Federation 2 uses ‘make-fetch-happen’ which is by default using strict SSL.
As workaround for local development you can create a custom datasource that sets the default options like that:
import { RemoteGraphQLDataSource } from '@apollo/gateway';
import * as fetcher from 'make-fetch-happen';
export class CustomDataSource extends RemoteGraphQLDataSource {
constructor(config: any) {
super(config);
this.fetcher = fetcher.defaults({
maxSockets: Infinity,
strictSSL: false,
retry: false,
});
}
}