grand-stack / grand-stack-starter

Simple starter project for GRANDstack full stack apps
https://grandstack.io/docs/getting-started-grand-stack-starter.html
Apache License 2.0
506 stars 161 forks source link

Unable to get custom file upload resolvers to work. How to debug? #93

Open bartonhammond opened 4 years ago

bartonhammond commented 4 years ago

Followed instructions here https://grandstack.io/docs/graphql-custom-logic/#implementing-custom-resolvers, but I'm not able to get the file upload resolvers to be recognized. With a breakpoint set w/in the resolver, it doesn't break. Not sure how to debug. I also looked at https://codesandbox.io/s/0on871118p

schema:

type File {
  id: String!
  path: String!
  filename: String!
  mimetype: String!
}

scalar Upload

type Mutation {
  singleUpload(file: Upload!): File! @neo4j_ignore
}

Resolvers:

const resolvers = {
  Mutation: {
    singleUpload:  (obj, args, context, info) => {
      console.log("singleUpLoad")
      storeUpload(file)
    }
  }
}
const schema = makeAugmentedSchema({
  typeDefs,
  resolvers
});

server:

const server = new ApolloServer({
  context: {driver, neo4jDatabase: process.env.NEO4J_DATABASE },
  uploads: {
    maxFileSize: 5000000, // 5 MB
    maxFiles: 2,
  },
  schema: schema,
  introspection: true,
  playground: true,
});
bartonhammond commented 4 years ago

I've been able to walk through the debugger and it appears that apollo-server-express automatically handles the file loading. It knows this because of the uploads config to ApolloServer. It appears to me that the call from the client is correct w/ the multi-part file input. But the mutation singleUpload is never called to handle the file.