jaydenseric / graphql-upload

Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.
https://npm.im/graphql-upload
MIT License
1.43k stars 132 forks source link

Setup with Meteor ? #63

Closed gaetandezeiraud closed 6 years ago

gaetandezeiraud commented 6 years ago

Hi, I'm new with Apollo and GraphQL. I see the setup instruction of this module is possible with Express. I believe Apollo create an express app on the server side with Meteor but it is completely opaque.

Any idea about setup apollo-upload-server on the server side with Meteor ? My main server code. (Apollo setup)

import { createApolloServer } from "meteor/apollo";
import { makeExecutableSchema } from "graphql-tools";
import merge from "lodash/merge";

import UsersSchema from '../../api/users/User.graphql';
import UsersResolvers from '../../api/users/resolvers';
import PagesSchema from '../../api/pages/Page.graphql';
import PagesResolvers from '../../api/pages/resolvers';
import CommonSchema from '../../api/common/Common.graphql';
import CommonResolvers from '../../api/common/resolvers';

const typeDefs = [UsersSchema, PagesSchema, CommonSchema];

const resolvers = merge(UsersResolvers, PagesResolvers, CommonResolvers);

const schema = makeExecutableSchema({
  typeDefs,
  resolvers
});

createApolloServer({ schema });

Thanks for your answer and great job for this project !

jaydenseric commented 6 years ago

As I don't use Meteor I'm not in a good position to help. Looking at https://github.com/jaydenseric/apollo-upload-server/issues/29#issue-282601315 it seems @windgaucho worked it out. Perhaps they can share some tips?

windgaucho commented 6 years ago

I'm sorry but I did not have much time to try, so I ended up using the meteor-files package (ostrio:files).

gaetandezeiraud commented 6 years ago

Thanks for your answer. Because i don't have many hours to make the project, i simply use Base64 images. And not this extension.

Thanks for your times.

jaydenseric commented 6 years ago

I don't intend to directly support Meteor, but if anyone manages to work out what it takes to get it working feel free to share the solution here 🙏

macrozone commented 6 years ago

@Brouilles

meteor usage is fairly simple:

import { createApolloServer } from 'meteor/apollo';
import { apolloUploadExpress } from 'apollo-upload-server';

 const schema = makeExecutableSchema(...);
 createApolloServer(
    {
      schema
    },
    {
      graphiql: true,
      configServer: expressServer => {
        expressServer.use(bodyParser.json({ limit: '5mb' }));
        expressServer.use(apolloUploadExpress());
      }
    }
  );
MiroHibler commented 5 years ago

According to the new naming, it's:

import { createApolloServer } from 'meteor/apollo';
import { graphqlUploadExpress } from 'graphql-upload';

 const schema = makeExecutableSchema(...);
 createApolloServer(
    {
      schema
    },
    {
      graphiql: true,
      configServer: expressServer => {
        expressServer.use(bodyParser.json({ limit: '5mb' }));
        expressServer.use(graphqlUploadExpress());
      }
    }
  );