Guys, which Scalar Type I must to add to a file fi...
# prisma-whats-new
v
Guys, which Scalar Type I must to add to a file field ? for example I have
Copy code
type Post @model {
id: ID! @isUnique
createdAt: DateTime! # read-only (managed by Graphcool)
updatedAt: DateTime! # read-only (managed by Graphcool)
author: User! @relation(name: "UserPosts")
description: String
imageUrl: String
image: <---- type ?????
likes: Int
}
Who knows how to add file to GraphQl from React native ?
p
I would maybe try posting the image to S3 or a service like cloudinary or filestack and store a reference to the URL
v
But in Graphcool we already have file API for this, and I want try to send post request to this API
p
Ok. If you take a look here: https://www.graph.cool/docs/reference/graphql-api/file-management-eer4wiang0/, the pattern is to store the file as it's own type, and reference the file in the relation
So you need something like this:
Copy code
type File @model {
  id: ID! @isUnique
  createdAt: DateTime! 
  updatedAt: DateTime!
  name: String
  url: String
  contentType: String
  post: Post @relation(name: "PostImage")
}

type Post @model {
  id: ID! @isUnique
  createdAt: DateTime! # read-only (managed by Graphcool)
  updatedAt: DateTime! # read-only (managed by Graphcool)
  author: User! @relation(name: "UserPosts")
  description: String
  image: File @relation(name: "PostImage")
  likes: Int
}
v
Yeah, thanks a lot, I already did it ) best wishes )