Skip to content

Conversation

@jim-spot
Copy link

If a Contentful content type contains a reference to one or many other entries, it is possible for the reference to be undefined in cases where the referenced entry is archived or deleted from Contentful.

Example:

Let's say I have a blog post which contains a reference to one or more categories, it might look something like this pseudodata:

MyBlogPost Categories: -> Category 1 -> Category 2 -> Category 3 

Let's say I delete or archive Category 2, the resulting pseudodata returned from contetnful will look like this:

MyBlogPost Categories: -> Category 1 -> undefined -> Category 3 

Today the rendered typescript interface looks something like this:

interface IBlogPost { categories: ICategory[]; }

But in order to account for the above scenario, it should look like this:

interface IBlogPost { categories: (ICategory | undefined)[]; }

Similarly for singular references, it currently looks like this:

interface IBlogPost { category: ICategory; }

But in order to account for the above scenario, it should look like this:

interface IBlogPost { category: ICategory | undefined; // category?: ICategory is more syntactically correct, but was easier to implement this way. }

Addresses: #86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant