hi everyone question not part of prisma but a gra...
# random
e
hi everyone question not part of prisma but a graphql what is the best way create a seperate type or just include it. for example instead of
type Location {}
jut include it as
Country: String!
City: String!
a
I've had that question, too. ATM my rule of thumb is: will I need to filter with Country or City? If not, then it's a good candidate for a new Type. I'm curious how others have approached this
e
but mine was different
Copy code
type Location {
  city: String!
  country: String!
}

type Restaurant {
  id: ID! isUnique
  location: Location!
}
or
Copy code
type Restaurant {
  id: ID! isUnique
  city: String!
  country: String
}
which is i need to filter the country and city i’m not sure what is the best in this implementation since i’m designer and just trying to explore GraphQL and React 🙂
a
I'd go with the latter 😄
e
^ but this is a simple goal so i don’t want to complex since this is only a listing no more special features at this moment.
d
You may be able to get away with the second one (I think you'd call it the "denormalized" version), but at some point you may want to add the ability to get a list of restaurants in a location:
Copy code
type Location {
   // ...
   restaurants: [Restaurant]!
}
which will require some work to transition to, but would be easier if you started with the first, "normalized", version (where Restaurant & Location are already split up).
I think both approaches could make sense, but it really depends on other requirements. The first approach may be faster to get going now, but may be a pain to migrate away from later.