Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly account for deleted or archived Reference/Links #141

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant