0

I am Using Connected GraphQL query to fetch the data of the item.

It works fine in the GraphQL editor. But I created a component called GraphQLDemo and used the that query and fetched the data and delpoyed the component to my local Sitecore instance, it gave me the following error:

Cannot read property 'value' of undefined`
TypeError: Cannot read property 'value' of undefined
   at GraphQLElements (D:\Websites_New\sc910JSS.local\dist\ssr\server.bundle.js:35011:269)
   at c (D:\Websites_New\sc910JSS.local\dist\ssr\server.bundle.js:14020:496)
   at Ga (D:\Websites_New\sc910JSS.local\dist\ssr\server.bundle.js:14023:1)
   at a.render (D:\Websites_New\sc910JSS.local\dist\ssr\server.bundle.js:14028:367)
   at a.read (D:\Websites_New\sc910JSS.local\dist\ssr\server.bundle.js:14027:450)
   at renderToString (D:\Websites_New\sc910JSS.local\dist\ssr\server.bundle.js:14039:82)
   at process (D:\Websites_New\sc910JSS.local\dist\ssr\server.bundle.js:22217:20)
   at process._tickCallback (internal/process/next_tick.js:68:7)

My Query is:

query ConnectedDemoQuery($contextItem: String!) {
  contextItem: item(path: $contextItem) {
    id
    ...RecursiveItems
  }
}

fragment RecursiveItems on Item {
  ...ItemData
  children(requirePresentation: true) {
    url(options: {disableLanguageEmbedding: true})
    ...ItemData
    children(requirePresentation: true) {
      url(options: {disableLanguageEmbedding: true})
      ...ItemData
    }
  }
}

fragment ItemData on Item {
  id
  path
  name
  fields {
    PageTitle: value
    heading: value
  }
}

Can anyone help with this?

  • check the datasource value in connected mode. – Hussain Mar 11 at 11:49
  • I have added Datasource value to my component,But still showing same error. – pratik kshirsagar Mar 11 at 12:16
  • The query looks weird, PageTitle and Heading contain both the field value and are equal.. (you can also use name instead of value to get the field name) But the error is in your JavaScript app. The GraphQL query works or at least do not throw an error if it works in the GraphQL editor with the same context. – Jan Bluemink Mar 11 at 12:26
  • My query is working fine in editor also it is giving correct result.my index.js file code is: – pratik kshirsagar Mar 11 at 13:01
  • Use connected mode to run the GraphQL query at the client-side for easier debugging. Then the network tab of your browser dev tools will let you inspect what's going on. Or, you can enable Node debugging to diagnose SSR: jss.sitecore.com/docs/techniques/ssr/… – Kam Figy Mar 11 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.