Improve GraphQL Schema for required fields

Required relations and fields should be represented in the schema with an exclamation mark at the end.

This would make it a lot easier to use automated code generation for TypeScript and Flow users.

hey @denis.augsburger thank you very much for your request!

Can you please provide an example of something that behaves as you are suggesting?

I couldn’t find a product that already implements this functionality.

In this video a contentful developer explaines at around the 10th minute: “Third design decision: Content Type Validations are re-used to derive links between types”.
My suggestion is to bring it a little bit further and re-use the Content Type Validations to define required/mandatory fields in the schema.

As an example: I define a blogPost with a required title and a required connection to an Author. I would expect the following SDL:

type BlogPost {
title: String!
author: Author!

As a result, the TypeScript Definitions can be correctly derived from the schema. Compare also with object types and fields

Thank you very much for the details, we’ll look into it!

Are you still looking into it? We are running into the exact same issue as denis.augsburger. If we cant trust the graphql schema, its quite hard derive types from schema that are trustable.