graphql upload express

Solutions on MaxInterview for graphql upload express by the best coders in the world

showing results for - "graphql upload express"
Élodie
21 Apr 2017
1
2//resolvers.js
3export default {
4	Query: {
5		usersActivation() {
6			return 'Hello Wordl'
7		}
8	},
9	Mutation: {
10		uploadFile: async (parent, { file }) => {
11			const { filename, createReadStream } = await file.promise
12			fileUpload({ filename, stream: createReadStream() })
13			return true
14		}
15	}
16}
17
18//typedefs.js
19export default gql(`
20	 scalar Upload
21
22	 type Query {
23		helloWordl : String!
24	 }
25
26	type Mutation {
27		uploadFile(file: Upload!): Boolean
28	  }
29	`)
30
31// util.upload.js
32const uploadFile = ({ filename, stream }) => {
33	stream
34		.pipe(createWriteStream(resolve(process.cwd(), `src/images/${filename}`)))
35		.on('finish', () => Promise.resolve())
36		.on('error', Promise.reject)
37}
38
39const validateFile = ({ filename, stream }) => {
40	const extFile = filename.replace('.', '')
41    
42	const extPattern = /(jpg|jpeg|png|gif|svg)/gi.test(extFile)
43	if (!extPattern) throw new TypeError('Image format is not valid')
44
45	const fileExits = existsSync(resolve(process.cwd(), `src/images/${filename}`))
46	if (!fileExits) return uploadFile({ filename, stream })
47
48	unlink(resolve(process.cwd(), `src/images/${filename}`), (error) => {
49		if (error) throw error
50		return uploadFile({ filename, stream })
51	})
52}
53
54export const fileUpload = ({ filename, stream }) =>
55	filename ? validateFile({ filename, stream }) : new Error('Image is required')
56
57
58// request query playground
59mutation UPLOAD_FILE($file: Upload!) {
60  uploadFile(file: $file)
61}
queries leading to this page
upload file graphql express serverupload file with graphqlreact graphql upload fileapollo graphql file upload examplegraphql upload imagegraphql file upload typegraphql file upload reactgraphql server upload filegraphql file upload mihojgraphql js upload a filegraphql server with file upload exampleupload file graphqligraphql upload filegraphql playground upload filesupload image in react apollo graphqlfile upload graphqlupload scalar typegraphql s3 file uploadergraphql media uploadgraphql upload expressgraphql upload fileupload read to stringupload files graphql querygraphql upload files playgroundsend file graphqlfile upload in graphql and ractgraphql upload type clientgraphql upload imagegraphql file upload node jshow to use upload files in graphql moduleinput for graphql upload filegraphql photo uploadapollo server uploadgraphql upload clienthow to upload file in graphql playgroundgraphene file uploadgraphql client upload filegraphql type uploadfileapollo graphql upload filegraphql file uplaodgraphql browser uploadlocally upload files graphqlfile upload in graphql with client servergraphql uploading filesgraphql apollo express upload fileuploads with 22graphql 22 serverfile upload example in graphqlgraphql client file upload upload file in graphql nide jsmock graphql upload fileapollo graphql upload file exampleupload file graphq and l express serverdifferent methods to upload file in graphqlgraphql upload filegraphql file upload testsfile upload graphql testsgraphql upload fileupload to stringnodejs express graphql upload filesgraphql file uploadgraphql spqr uploadgraphql upload file reactupload image graphql serverupload image graphqlcan you upload files to graphqlfile upload to apollo servergraphql uploadgraphql file upload with apollofedarationgraphql image uploadgraphql upload and read filehow to upload through graphqlapollo server file uploadcan we upload file using graphqlgraphql upload documentgraphql file upload in playgroundgraphql upload client imageexpress graphql file uploadgraphql file upload schemagraphql fetch upload file examplegraphql fileuploadshow to upload a file graphqlgraphql file upload mirohgraphql upload examplegraphql upload examplegraphql video uploadgraphql document uploadcan you upload file with graphql apifile upload with graphqlwhat is the best way to upload graphql filefile upload graphql apolloupload type apollo servergraphql file upload specificationhandling graphql file uploadsfileupload graphqlgraphql file upload miadd upload scalar to apolloupload file graphql and l express servergraphql file upload prupload with graphqlhow to handle file upload with graphqlupload 21 graphql apollo mutationgraphql file uploadsgraphiql upload filenode js graphql file uploadgraphql get file with upload valuefile uploads apollo reactgraphql upload nodejs get graphql file upload pathgraphql upload files without clienthow to upload files in graphql playgroundhow to upload image with graphqllinux graphql file uploadgraphql request file uploadhow to upload file in graphql altairimage upload to graphqlupload files in graphql clientapollo graphql file uploadgraphql file upload nodejsgraphql uploargraphql file and uploadgraphql form uploadgraphql how to upload filegraphql fileuploadalter graphql client upload filegraphql upload filefile upload in graphqlgraphql file uploadingupload function graphql jsapollo server file upload mutationtype graphql file uploadgraphql file upload downloadupload image using graphqlgraphql upload files streaemhow to check image size in apollo server graphqlgraphql new uploadimage upload option in graphqlgraphql upload filesgraphql upload file fron clientgraphql upload readerbest graphql client file uploaduploadfile graphqlhow to upload file using graphqlis it okay to upload file in graphqlhow to upload throgh graphqlgraphql client for file uploadfile upload using graphqlgraphql apollo upload filegraphql upload file frontendfile uploading graphqlgraphql upload serverusing graphql upload exampleupload file post api in graphql requestgraphql playground upload filejava graphql uploadhow to upload files in graphqlfile upload axuios graphqlapollo file uploads graphqlgraphql uploadsupload file via graphqlupload files graphqlworth of upload files using graphqlupload file apollo graphqlupload file in graphqlfile upload in graphql v2how to upload file in graphqltype graphql upload fileupload file in graphql and storeupload file directus graphqlhow to check image in apollo server graphqlgraphql upload file with express serverexpress graphql upload imagegraphql file upload examplegraphql upload express