Closed shriram10567 closed 3 years ago
i apologize for creating a new issue but i have tried everything for the past few days to no avail.
this my apollo client code
const httpLink = new createUploadLink({ uri: 'http://localhost:4001/graphql', credentials: 'include', headers: { cookie: (typeof window === 'undefined' ? ctx?.req?.headers.cookie : undefined) || '', }, })
on the node server, i have used upload:false as per apollo docs.
const server = new ApolloServer({ uploads: false ..... })
this is what my resolver looks like
@Mutation(() => Boolean) async addPicture( @Arg('picture', () => GraphQLUpload) { createReadStream, filename }: Upload ): Promise<boolean> { console.log(filename) return new Promise((resolve, reject) => createReadStream() .pipe(createWriteStream(__dirname + `../images/${filename}`)) .on('finish', () => resolve(true)) .on('error', () => reject(false)) ) }
i am getting the following error: Error: Unexpected token P in JSON at position 0.
P.S. before marking this as closed, please look at this stackoverflow post: https://stackoverflow.com/questions/64971480/cant-upload-files-with-apollo-client-graphql-in-next-js-app-post-body-missing. this post explain the problem better than i have done here
Duplicate of https://github.com/jaydenseric/graphql-upload/issues/241.
i apologize for creating a new issue but i have tried everything for the past few days to no avail.
this my apollo client code
on the node server, i have used upload:false as per apollo docs.
this is what my resolver looks like
i am getting the following error: Error: Unexpected token P in JSON at position 0.
P.S. before marking this as closed, please look at this stackoverflow post: https://stackoverflow.com/questions/64971480/cant-upload-files-with-apollo-client-graphql-in-next-js-app-post-body-missing. this post explain the problem better than i have done here