Skip to content

Live Preview conflicts with extensions ('Cannot read properties of undefined (reading 'find')) #227

Description

@ignxn

I'm configuring live preview and added cslp__meta to my GraphQL queries. However, for one query, cslp__meta returns an object like this:

cslp__meta: {
    "error": {
        "message": "Cannot read properties of undefined (reading 'find')"
    }
}

This error occurs in node_modules/gatsby-source-contentstack/live-preview/getCslpMetaPaths.js at line 86:

var nestedFieldSchema = nestedFields.find(function (item) {
    return item.uid === selection.name.value;
});

I logged the schema variable inside getCslpMetaPaths and got the following output:

{
  display_name: 'Structured Data',
  extension_uid: 'blt12f5384289a03f97',
  field_metadata: {
    extension: true,
    instruction: 'JSON-LD structured data (schema.org)'
  },
  uid: 'structured_data',
  mandatory: false,
  multiple: false,
  non_localizable: false,
  unique: false,
  config: {},
  data_type: 'json'
}

This field uses the prebuilt JSON Editor extension: JSON Editor.

Field in GraphQL query:

 seoStructuredData: structured_data {
      structuredDataJson
    }

After I removed the structured_data field from my GraphQL query, the cslp__meta error disappeared, and it now contains the correct metadata.

I encountered a similar issue with another GraphQL query, where a field used the Color Picker extension: Color Picker.

Field in GraphQL query:

headerColor: header_color {
    hex
 }

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions