Vincit / objection-graphql

GraphQL schema generator for objection.js
MIT License
307 stars 34 forks source link

Make required fields required; to-one relations don’t need arguments #15

Open mattleff opened 7 years ago

mattleff commented 7 years ago

This makes the types generated more accurate:

type Review {
  id: Int
  title: String
  stars: Int
  text: String
  reviewerId: Int!
  movieId: Int!
  reviewer: Person!
  movie: Movie!
}
koskimas commented 7 years ago

Does this make any sense? If a property is needed when creating or updating a model it doesn't necessarily mean that it needs to be selected when querying? That's what json schema is in objection: an input validation schema and nothing else. Or is that what required means in graphql (I have never used it)?

mattleff commented 7 years ago

@koskimas As the spec explains:

Fields are always optional within the context of a query, a field may be omitted and the query is still valid. However fields that return Non‐Null types will never return the value null if queried.

So, I'm not quite using the correct term. This should be called Make required fields non-null.