Skip to content

Schema definition issues with solution for Gatsby source plugin Kontent

License

Notifications You must be signed in to change notification settings

Simply007/schema-definition-changes

Repository files navigation

Schema definition issues with solution for Gatsby source plugin for Kontent

Issues

Solution

Queries with complicated filter:

  query BeltIdentifierTypeQuery(
    $url_slug: String!
    $language: String!
  ) {
    pitches: allKontentItemBeltPitch(
      filter: {
        usedByContentItems: {
          elemMatch: {
            system: { type: { eq: "belt_series" } }
            elements: {
              belt_type: {
                linked_items: {
                  elemMatch: {
                    elements: { url_slug: { value: { eq: $url_slug } } }
                  }
                }
              }
            }
          }
        }
      }
      ...

Could be extracted to isUsedInBeltSeries and beltTypeUrlSlug fields precalculated in gatsby-node.js and then use in the filter:

Example

query getPitchesInBeltSeriesByUrlSlug($url_slug: String!) {
  allKontentItemBeltPitch(filter: {fields: {beltTypeUrlSlug: {eq: $url_slug}, isUsedInBeltSeries: {eq: true}}}) {
    nodes {
      internal {
        type
      }
      system {
        name
        codename
      }
      ...
    }
  }
}

i.e. with query variables:

{
  "url_slug": "belt-type-1"
}

How to run

git clone --recurse-submodules github.com/Simply007/schema-definition-changes
# this automatically clones the plugin sub module to /plugins/@kentico/gatsby-source-kontent
cd schema-definition-changes
cd plugins/@kentico/gatsby-source-kontent
# (optional) checkout proper version
# git checkout tags/4.3.0
npm install
npm run build
cd ../../..
npm install
npm run develop

How to connect to own project

  1. Perform steps from How to run (except of the gatsby develop)
  2. Register on Kentico Kontent
  3. Create an empty project
  4. Enable Content Management API
  5. Import content.zip data using Template manager
    • Use Project Id and Content Management API key from previously generated project.
  6. Place the ProjectId to the /gatsby-config.js configuration file.
  7. run npm run develop

About

Schema definition issues with solution for Gatsby source plugin Kontent

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published