You add a publishedAt date field to your Article type in ContentGrid. Immediately, your REST API response includes a publishedAt ISO 8601 string. Your GraphQL schema gains a publishedAt: DateTime field. Your TypeScript SDK types update to include publishedAt: Date. One decision, three places updated automatically.
How Fields Become API Properties
ContentGrid maps each field type to a specific API output format. Text fields return strings. Number fields return integers or floats. Date fields return ISO 8601 strings. Rich text fields return structured JSON — not HTML strings — so your frontend can render them however it wants. Reference fields return the linked entry's ID by default, with an option to expand them into inline objects in a single query.
This mapping is predictable and documented, which means your TypeScript types match your API response exactly. There's no runtime surprise where a field you defined as a number comes back as a string because the CMS serialised it differently.
Field Types and Their API Shapes
- Short text: Returns a plain string. Use for titles, slugs, labels.
- Rich text: Returns a structured JSON document with node types like
paragraph,heading,list. Render it with a custom renderer in your Next.js components. - Reference (single): Returns an object with
idandtype, or the full entry when expanded. - Reference (multiple): Returns an array. Use for related posts, feature lists, or navigation items.
- Boolean: Returns
trueorfalse. Use for feature flags likeisFeaturedorshowInNav. - JSON: Returns raw JSON. Use sparingly, for data that doesn't fit a structured type.
Validations as API Contracts
Validation rules aren't just editor guardrails — they're implicit API contracts. If you mark a field as required, the API will never return an entry where that field is null. If you set a maximum character count on a slug field, you can safely truncate display logic in your frontend knowing the value won't exceed that length. Design validations with the API consumer in mind, not just the editor experience.
From Schema to TypeScript SDK
ContentGrid's TypeScript SDK generates interfaces from your schema automatically. Run the SDK's type generation command and you get a Article interface with every field typed correctly. Your Next.js getStaticProps or server component can import that interface and get full autocomplete and compile-time checking on every API response. The schema you designed in the CMS becomes the type system your frontend depends on.
Ready to start tracking your competitors?
ContentGrid automatically monitors competitor websites, emails, and social media — and delivers structured intelligence straight to your inbox.