kontent-ai / delivery-sdk-js

Kontent Delivery SDK for Javascript
https://kontent.ai
MIT License
50 stars 34 forks source link

Content item name "Constructor" breaks previewDeliveryClient query #388

Closed boris-pocatko-fluent closed 8 months ago

boris-pocatko-fluent commented 8 months ago

Brief bug description

What went wrong?

image

The following query results in an error:

const query = await previewDeliveryClient
.items<ApprovedEmailDomainContentType>()
.queryConfig({ usePreviewMode: true })
.type(contentTypesCodename.approvedEmailDomain)
.elementsParameter(['approved_domain'])
.depthParameter(0)
.toAllPromise();

If I create a new content item with the content item name Constructor.

Repro steps

  1. Create a content item name with the name Constructor
  2. Run the above query

Expected behavior

What is the correct behavior?

Test environment

IvanKiral commented 8 months ago

Hey @boris-pocatko-fluent :)

right now, I don't see a problem with the name Constructor. Why do you think that this is the problem?

Also please could you provide me please with the look of the ApprovedEmailDomainContentType, so I could replicate the issue?

From the error I guess the problem relates to the LinkedItems. Do you have linked items in your type?

Thank you :)

boris-pocatko-fluent commented 8 months ago

Hey @IvanKiral ,

If I create any content item the query executes, if I create one with the content item name Constructor it fails. I assume as it may conflict with a reserved programming structure in the SDK.

The content model is pretty basic without linked items:

image
IvanKiral commented 8 months ago

Thank you,

I was able to reproduce the mistake, and you are right. SDK also cannot handle names of the object methods like toString and so on. We will look into it

Enngage commented 8 months ago

Hey @boris-pocatko-fluent , still using Kontent, are you? 😄

I've released 14.7.0 which should fix this issue ;) Can you see if that helped in your case as well? Thanks for letting us know!