-
Notifications
You must be signed in to change notification settings - Fork 27
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
Apollo gateway - file upload "missing operations" error on micro-service #46
Comments
@Narendra67 did you add the Upload resolver? https://github.com/profusion/apollo-federation-file-upload/blob/master/test/gen-service.ts#L128 Also take a look at the apollo server docs on how to properly setup file uploads. https://www.apollographql.com/docs/apollo-server/data/file-uploads/ |
I had the same problem, Upload function works on sub-graphql but not with gateway.
const gateway = new ApolloGateway({
supergraphSdl,
buildService({ name, url }) {
return new AuthenticatedDataSource({ url, useChunkedTransfer: true });
},
}); |
@truongduchuy910 this looks like that your GraphQL client is not properly sending the multipart data. Did you configure your apollo client correctly? Assuming that you're using apollo-client on JS you should use: https://www.npmjs.com/package/apollo-upload-client |
@cabelitos Thanks! I solved. The error caused by using wrong way to set headers. Solutionreplace |
awesome. |
i'm experiencing the same issue. i have pretty much the same setup as @truongduchuy910. import { createUploadLink } from 'apollo-upload-client';
const createClient = () => {
const link = ApolloLink.from([
new RetryLink({ attempts: { max: 3 } }),
createUploadLink({ uri: `${getBaseUrl()}/api/graphql`, fetch }),
]);
return new ApolloClient({
connectToDevTools: isClient(),
ssrMode: isServer(),
link,
cache: new InMemoryCache(),
});
}; The buildservice is also extends FileUploadDataSource, Both the gateway and service have: app.use(
graphqlUploadExpress({
maxFileSize: configService.get('service.maxFileSize'),
})
); I'm stumped |
@Mporsi show your function willSendRequest({ request, context }) {
if (context.req) {
const { cookie, authorization, referer, as } = context.req.headers;
if (cookie) request.http.headers.set("cookie", cookie);
if (authorization) request.http.headers.set("authorization", authorization);
}
}
const gateway = new ApolloGateway({
supergraphSdl,
buildService({ name, url }) {
return new FileUploadDataSource({
url,
useChunkedTransfer: true,
willSendRequest,
});
},
}); |
I can verify that the headers are forwarded alright, I'm adding several on top. It seems like it's the initialization of FileUploadDataSource that is messing up, I assumed that because I was inheriting from FileUploadDataSource it would pick up willSendRequest as well, maybe that is untrue? #edit: buildService: ({ url }) => {
new FileUploadDataSource({ url });
}); Im left with another error, which I'm also unsure what the deal is with.
I don't get this same error if I query directly to the service #second edit I made it work alright, my issue was that the type I had on the service didn't match the type passed, I had created my own scalar for upload, which didn't work, I changed my type to
both from the package 'graphql-upload' |
Yeah, it's imperative to configure file upload in apollo-server first. Always check https://www.apollographql.com/docs/apollo-server/data/file-uploads/#integrating-with-express on how to do it! Glad that it's working. |
Looks like this is solved, if no response in the next weeks I will close this issue. |
On gateway i'm using
app.use(graphqlUploadExpress())
from 'graphql-upload' library, and on service also i'm using same middleware. And I'have extended my "AuthenticatedDataSource" with "FileUploadDataSource"export default class AuthenticatedDataSource extends FileUploadDataSource {
Still im getting operations missing error on the service. am I missing something here.
The text was updated successfully, but these errors were encountered: