-
-
Notifications
You must be signed in to change notification settings - Fork 818
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
Merging schemas that use apollo-upload-server #671
Comments
This issue blocks us from using |
@GuilhermeMedeiros @rohit-ravikoti have you managed to resolve this ? I have stumbled uppon same issue... |
@marhub I had to implement |
A side-note for those unfamiliar with the change, but |
Hello, |
This is also blocking me, I have to bypass the gateway until this works. This guy has implemented some kind of workaround into apollo-upload-client and describes the process in the readme of the PR: jaydenseric/apollo-upload-client#79 Sadly the author closed the PR but @jaydenseric left an idea there, mentioning that extract-files could be patched allowing streams. Workaround partial: https://github.com/jaydenseric/apollo-upload-client/pull/79/files#diff-0730bb7c2e8f9ea2438b52e419dd86c9 |
+1 |
graphql-tools-fork v8.1.0 provides support for proxying remote file uploads for those who want to proxy all the things. The new createServerHttpLink method should be used to set up a terminating link to a subschema; it will resolve all promises within the variables, and then, if appropriate, append the File or stream to the FormData. The GraphQLUpload scalar export from graphql-tools-fork is a one-line code change from the original from the graphql-upload package that allows use on the gateway. Feedback/critiques/suggestions would be much appreciated. I am happy to submit PRs where appropriate, this is more POC. Please join in further discussion at: jaydenseric/apollo-upload-client#172 (comment) |
We recently released an alpha version of GraphQL Tools (#1308) that should fix the issue. Please update
Let us know if it solves the problem, we're counting for your feedback! :) |
Rolled into #1306 |
I assume that how that the issue is closed this comment should be removed ardatan/graphql-tools#671
This is the first result on google and it's not super clear on how to fix the issue or why this happens. TL;DR change the import of Also see #2795 (comment) and jaydenseric/graphql-upload#194 about the reason why this throws an error. const { makeExecutableSchema } = require('graphql-tools');
- const { GraphQLUpload } = require('graphql-upload');
+ const { GraphQLUpload } = require('@graphql-tools/links');
const schema = makeExecutableSchema({
typeDefs: /* GraphQL */ `
scalar Upload
`,
resolvers: {
Upload: GraphQLUpload,
},
}); |
Actually, the subschema can use the original scalar. The gateway schema needs to use the modified scalar. See fully worked example at https://github.com/ardatan/graphql-tools/blob/20a066e17669f66324486e978ac66c8f1c6ce100/packages/links/tests/upload.test.ts |
@yaacovCR thank you for the clarification. Updated code snippet below. // schema.js
const { makeExecutableSchema } = require('graphql-tools');
const { GraphQLUpload } = require('graphql-upload');
const schema = makeExecutableSchema({
typeDefs: /* GraphQL */ `
scalar Upload
`,
resolvers: {
Upload: GraphQLUpload,
},
});
// makeGatewaySchema.js
import { stitchSchemas } from "@graphql-tools/stitch";
import { GraphQLUpload as ServerGraphQLUpload } from "@graphql-tools/links";
const gatewaySchema = stitchSchemas({
subschemas: [schema],
resolvers: {
/* ADD THIS */
Upload: ServerGraphQLUpload,
},
}); |
Minor nit with my test code, term ServerGraphQLUpload is silly, these two schemas should be living on two different servers, so that both or neither should be called that. When I have time, I should change to GatewayGraphQLUpload. The name came from the fact that it is being used together with a server side HttpLink |
@yaacovCR I thought my previous comment 2 worked but it's actually throwing an error. My first attempt does work comment 1. My setup: I have one local schema that includes
|
Can’t really say, linked test code seems pretty similar to your setup from your description, consider putting together a PR with a failing test off of that and we can try to see what we can see |
@yaacovCR I made a PR gmac/schema-stitching-handbook#30 to the schema stitching handbook to reproduce the error. I copied the example |
Hello,
Is there any way to merge schemas that use apollo-upload-server? Here is a contrived example:
Basically, the
Upload
does not get forwarded to the schema and resolvers. I just get an empty picture object from the args.If I use
UploadScalar
directly for the schema (const server = new GraphQLServer({ schema: UploadScalar })
), it works. Of course, I don't do this in a real-world scenario. I would be merging multiple remote schemas which may use apollo-upload-server.Does anyone know of a way I could work around this?
The text was updated successfully, but these errors were encountered: