Hi,
I’m trying to upload a file to springboot microservice
In the client side am using apollo-upload -client package to send file from client to apollo server.
In apollo server , using @profusion/apollo-federation-upload package to enable file uploads.
I’m attaching my code to run apollo server here
const { ApolloServer } = require(‘apollo-server’);
const { ApolloGateway} = require(‘@apollo/gateway’);
const { readFileSync } = require(‘fs’);
const FileUploadDataSource = require(‘@profusion/apollo-federation-upload/build/FileUploadDataSource.js’);
const supergraphSdl = readFileSync(‘supergraph.graphql’).toString();
class AuthenticatedDataSource extends FileUploadDataSource{
willSendRequest({request,context}) {
request.http.headers.set(“bearer”, context.token);
request.http.headers.set(“role”, context.role);
}
}
const gateway = new ApolloGateway({
supergraphSdl, buildService : ({url}) => new AuthenticatedDataSource({url})
});
const server = new ApolloServer({
gateway,
context: ({req}) => {
const token = req.headers.bearer || ‘’;
const role = req.headers.role || ‘’;
return { token , role}
},
subscriptions: false
});
server.listen().then(({ url }) => {
console.log(🚀Server ready at ${url}
)
});
While running this code ,I always getting this below error
Am adding the versions of each package also here
“@apollo/gateway”: “^2.4.1”,
“@profusion/apollo-federation-upload”: “^4.0.0”,
“apollo-server”: “^3.12.0”,
“fs”: “^0.0.1-security”,
“graphql”: “^16.6.0”
Error is in extending FileUploadDataSource class , can anyone please help me to resolve this error