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
How to get working with mergeSchemas #56
Comments
I can't see an |
@jaydenseric, you're right. Sorry, I used a bad example. Here is a better one:
The remote schema is graphql-yoga (with the same mutation) and I'm simply trying to forward any requests through. If I call that service directly, I correctly get this as the args in the remote schema:
However, if I call the gateway which forwards the mutation to the remote schema, I get this: |
Hi all, the same here. It doesn't forward multipart requests from the gateway (where the schemas were merged) to the microservices. Well this is all that I'm able to tell, correct me if I'm wrong! |
Interesting, I have not worked with remote merged schemas yet so I'm not in a good position to chip in. I am working day and night getting ready to announce |
This issue was mentioned in the Apollo Slack. Perhaps it relates? Sorry I have not immersed much. |
Yeah, it seems to be related, but I see that it's also an open issue here. From my understanding, with a For instance, the way The other issue is that these Promises will only be resolved one by one, so if we get multiple files and you have to forward them to another server the first Promise is already resolved, but the second will only be after you have drained the first stream, so this makes even harder to get the Any suggestion? |
@danielmeneses did you handle this? In my case with gateway on import {HttpLink} from 'apollo-link-http';
import fetch from 'node-fetch';
import express from 'express'
import * as bodyParser from 'body-parser-graphql'
import { apolloUploadExpress, GraphQLUpload } from 'apollo-upload-server'
import {graphiqlExpress, graphqlExpress} from 'apollo-server-express'
import {
introspectSchema,
makeRemoteExecutableSchema,
} from 'graphql-tools'
import {weaveSchemas} from "graphql-weaver";
import jwt from 'jsonwebtoken';
import createLocaleMiddleware from 'express-locale';
import fetchServices from "./utils/fetchServices";
require('dotenv').config();
const cors = require('cors');
const start = async function () {
const app = express();
const PORT = process.env.PORT || 3000;
app.use(cors());
app.post('/graphql', bodyParser.graphql());
app.post('/graphql', apolloUploadExpress());
app.use('/graphql', async function (req, res, next) {
// should to fetch this dynamically
const services = await fetchServices();
const serviceContainers = await Promise.all(services.map(async (service) => {
const dosvitMeta = req._dosvit;
const headers = {};
// ... some magic with headers
const link = new HttpLink({uri: service.url, fetch, headers});
const remoteSchema = makeRemoteExecutableSchema({
schema: await introspectSchema(link),
link
});
return {service, remoteSchema};
}));
const transformedSchema = await weaveSchemas({
endpoints: serviceContainers.map(s => {
return {
typePrefix: s.service.prefix,
namespace: s.service.namespace,
schema: s.remoteSchema
}
})
});
return graphqlExpress({schema: transformedSchema})(req, res, next);
});
app.use('/graphiql',
graphiqlExpress({
endpointURL: '/graphql',
}),
);
app.listen(PORT);
};
start(); It just fails entirely:
|
Hey @terion-name , I've forked the repo and I did my own implementation supporting file stream (server-side) but I didn't create any npm package. Have a look here. |
@danielmeneses thank you! I'll investigate it |
Nice work @danielmeneses ! Why don't you try making a PR so we can use it as an npm package ? I'm using your code and it's working perfectly fine. Thanks ! |
Hi @tlgimenes, thanks. In fact, I've tried a PR already, but I guess that the repo owner got a bit apprehensive with the number of changes there were to make it work so I never got any definitive answer and I decided to cancel the PR. But I definitely understand your request, I'd also prefer to have it at npm. |
Here is the PR @danielmeneses is referring to: jaydenseric/apollo-upload-client#79. |
I've been fighting with this for a couple of days now. |
Hi @GuilhermeMedeiros, I got you!! yes, it would be great to have that in place where we'd only need to use thanks |
The right place for this question to be answered is ardatan/graphql-tools#671, since schema merging is a Whatever the solution ends up being, it probably won't involve Also, a reminder that I monitor the |
@jaydenseric - I was trying the file upload post schema stitching. const PORT = 9000; /----------------First End Point----------------------------------/ async function createRemoteSchematest1() { const schema = await introspectSchema(link); return makeRemoteExecutableSchema({ const storeUpload = ({ stream, filename }) => /----------------Second End Point----------------------------------/ const schema = await introspectSchema(link); return makeRemoteExecutableSchema({ function searchOriginalError(error) { function createStitcherSchema() {
}); async function createCombinedSchema() { // STEP 4: Merge Schemas (async () => { const app = express(); app.use(cors()); app.listen(PORT, () => {
|
@tlgimenes, How did you implement @danielmeneses's sollution?? |
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) |
Hello,
I am trying to get this working with graphql-tool's mergeSchemas feature. 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: