Reputation: 935
I'm working on a react-native app, and I was wondering if graphql can return an image file as opposed to json, i.e. content-type - (image/jpeg etc).
<Image source={{uri: 'http://localhost/graphql?query{getImage(imageId)}'}}
style={{width: 400, height: 400}} />
Is this possible? or do i have to create a separate non-graphql server to achieve this?
Upvotes: 3
Views: 4608
Reputation: 1922
GraphQL servers can return images. If you're looking for a good GraphQL client image handler, check out this library.
The way that Scaphold handles it is by appending the image using FormData and then in the variables references that key where the image is stored. Then on the GraphQL server, you can have a piece of middleware that plucks the image off of that key and you can then handle it however you wish.
Here's how it would work from the client.
Hope this helps!
Upvotes: 3