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

CTF-next: use union for reference fields with validation #31395

Conversation

axe312ger
Copy link
Collaborator

@axe312ger axe312ger commented May 12, 2021

The current state allows you to query all content types in a reference field, even when the user/editor can not select it based on Contentful's field validations.

This change will adjust the schema to reflect the decisions made in the Contentful reference field validations.

Note: This is blocked from merging till Contentful CDA API delivers single reference field validations. A patch for the API is in progress :)

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 12, 2021
@axe312ger axe312ger force-pushed the feat/contentful-schema-generation-references branch 2 times, most recently from a435455 to c3d64b4 Compare May 12, 2021 17:31
@LekoArts LekoArts added topic: source-contentful Related to Gatsby's integration with Contentful and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels May 17, 2021
@axe312ger axe312ger force-pushed the feat/contentful-schema-generation branch 2 times, most recently from 95366fc to 4656166 Compare May 20, 2021 14:10
@axe312ger axe312ger force-pushed the feat/contentful-schema-generation-references branch from c3d64b4 to 2e685a4 Compare May 20, 2021 14:16
@axe312ger
Copy link
Collaborator Author

axe312ger commented May 20, 2021

Unfortunately field validations are not exposed for single reference fields. This blocks us from finishing this feature.

I escalated this problem to the Contentful API team. Will keep u posted if I hear back.

Here is a example response from CDA content-types:

{
  "id": "oneItemSingleType",
  "name": "One Item: Single Type",
  "type": "Link",
  "localized": false,
  "required": false,
  "disabled": false,
  "omitted": false,
  "linkType": "Entry"
}
{
  "id": "oneItemManyTypes",
  "name": "One Item: Many Types",
  "type": "Link",
  "localized": false,
  "required": false,
  "disabled": false,
  "omitted": false,
  "linkType": "Entry"
}
{
  "id": "oneItemAllTypes",
  "name": "One Item: All Types",
  "type": "Link",
  "localized": false,
  "required": false,
  "disabled": false,
  "omitted": false,
  "linkType": "Entry"
}
{
  "id": "multipleItemsSingleType",
  "name": "Multiple Items: Single Type",
  "type": "Array",
  "localized": false,
  "required": false,
  "disabled": false,
  "omitted": false,
  "items": {
    "type": "Link",
    "validations": [
      {
        "linkContentType": [
          "text"
        ]
      }
    ],
    "linkType": "Entry"
  }
}
{
  "id": "multipleItemsManyTypes",
  "name": "Multiple Items: Many Types",
  "type": "Array",
  "localized": false,
  "required": false,
  "disabled": false,
  "omitted": false,
  "items": {
    "type": "Link",
    "validations": [
      {
        "linkContentType": [
          "number",
          "text"
        ]
      }
    ],
    "linkType": "Entry"
  }
}
{
  "id": "multipleItemsAllTypes",
  "name": "Multiple Items: All Types",
  "type": "Array",
  "localized": false,
  "required": false,
  "disabled": false,
  "omitted": false,
  "items": {
    "type": "Link",
    "validations": [],
    "linkType": "Entry"
  }
}

@axe312ger axe312ger force-pushed the feat/contentful-schema-generation branch from 4656166 to 61f846c Compare June 10, 2021 15:37
@axe312ger axe312ger force-pushed the feat/contentful-schema-generation branch from 61f846c to a5ddad2 Compare June 10, 2021 16:06
@axe312ger axe312ger added the breaking change If implemented, this proposed work would break functionality for older versions of Gatsby label Jun 11, 2021
@axe312ger axe312ger force-pushed the feat/contentful-schema-generation branch from 849e5a3 to 05324da Compare July 12, 2021 12:26
@axe312ger axe312ger force-pushed the feat/contentful-schema-generation-references branch from a0d7001 to 15ab773 Compare July 12, 2021 12:35
@axe312ger axe312ger force-pushed the feat/contentful-schema-generation branch 2 times, most recently from 4f7e213 to 3a03727 Compare July 27, 2021 09:29
@axe312ger axe312ger force-pushed the feat/contentful-schema-generation-references branch from 15ab773 to f2916cc Compare July 27, 2021 09:34
@axe312ger axe312ger force-pushed the feat/contentful-schema-generation-references branch from 6f85503 to d670466 Compare July 28, 2021 07:43
@axe312ger
Copy link
Collaborator Author

We got a patch ready that exposes the field validation for single reference fields.

I'll merge this PR into #30855 as soon we released the updated API to the public.

Screenshot 2021-07-28 at 12 58 48

@axe312ger axe312ger marked this pull request as ready for review July 28, 2021 12:06
@axe312ger axe312ger marked this pull request as draft November 11, 2021 11:03
@axe312ger axe312ger force-pushed the feat/contentful-schema-generation branch from 380d85b to c342248 Compare November 18, 2021 14:26
@axe312ger axe312ger force-pushed the feat/contentful-schema-generation-references branch from 953c3e2 to 266ef16 Compare November 18, 2021 17:01
@axe312ger axe312ger changed the title CTF-v6: use union for reference fields with validation CTF-next: use union for reference fields with validation Nov 19, 2021
@axe312ger axe312ger force-pushed the feat/contentful-schema-generation-references branch from 266ef16 to 0468b64 Compare November 26, 2021 14:04
WIP - first try to use union for reference field with validations

fix multi reference fields

shorten union names

support multiple reference fields for a single content type

fix: type name generation

remove comment

introduce validation for single reference fields
@axe312ger axe312ger force-pushed the feat/contentful-schema-generation-references branch from 0468b64 to bf317a5 Compare November 29, 2021 13:18
@axe312ger
Copy link
Collaborator Author

Looks good now. Will add tests and merge into main PR :)

@axe312ger axe312ger marked this pull request as ready for review November 29, 2021 13:19
@axe312ger axe312ger merged commit 5ce5b86 into feat/contentful-schema-generation Nov 29, 2021
@axe312ger axe312ger deleted the feat/contentful-schema-generation-references branch November 29, 2021 15:38
axe312ger added a commit that referenced this pull request Jan 6, 2022
Also:

* test: add unit tests for schema customization

* fix: rich text inline rendering

* test: update e2e test schema dump
axe312ger added a commit that referenced this pull request Jan 14, 2022
Also:

* test: add unit tests for schema customization

* fix: rich text inline rendering

* test: update e2e test schema dump
axe312ger added a commit that referenced this pull request Feb 2, 2022
Also:

* test: add unit tests for schema customization

* fix: rich text inline rendering

* test: update e2e test schema dump
axe312ger added a commit that referenced this pull request Mar 9, 2022
Also:

* test: add unit tests for schema customization

* fix: rich text inline rendering

* test: update e2e test schema dump
axe312ger added a commit that referenced this pull request Apr 14, 2022
Also:

* test: add unit tests for schema customization

* fix: rich text inline rendering

* test: update e2e test schema dump
axe312ger added a commit that referenced this pull request May 17, 2022
Also:

* test: add unit tests for schema customization

* fix: rich text inline rendering

* test: update e2e test schema dump
axe312ger added a commit that referenced this pull request May 24, 2022
Also:

* test: add unit tests for schema customization

* fix: rich text inline rendering

* test: update e2e test schema dump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change If implemented, this proposed work would break functionality for older versions of Gatsby topic: source-contentful Related to Gatsby's integration with Contentful
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants