Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 1 replies, has 2 voices.

Last updated by Long Nguyen 10 months, 1 week ago.

Assisted by: Long Nguyen.

Author Posts
August 27, 2024 at 8:41 am #16108266

jakeS-3

Background of the issue:
I frequently use `nodeByUri` from WPGraphQL to query node content, especially when the post type is unknown to the front end. I was attempting to use the following queries:

query GetPageById {
page(id: "/", idType: URI) {
id
title
content
}
}

query GetNodeByUri {
nodeByUri(uri: "/") {
id
... on Page {
title
content
}
}
}

Symptoms:
When using `page(…)` or `post(…)` everything works as expected, but after updating to WPML WPGraphQL 1.1.0 I get an error message. Queries to `page` and `post` result in the expected data:

{
"data": {
"page": {
"id": "…=",
"title": "…",
"content": "…"
}
}

However, when using `nodeByUri` I get:

{
"errors": [
{
"debugMessage": "item should be a Collection or an array or an object",
"message": "Internal server error",
"extensions": {
"category": "internal"
},
"locations": [
{
"line": 10,
"column": 3
}
],
"path": [
"nodeByUri"
]
}
],
"data": {
"nodeByUri": null
},
"extensions": {
"debug": [
{
"type": "DUPLICATE_FIELD",
"message": "You cannot register duplicate fields on the same Type. The field 'language' already exists on the type 'page'. Make sure to give the field a unique name.",
"field_name": "language",
"type_name": "page",
"existing_field": {
"type": {},
"description": "ContentNode language",
"resolve": [
{
"helpers": {}
},
"resolveLanguageField"
],
"name": "language"
},
"duplicate_field": {
"type": "Language",
"description": "Page language",
"resolve": [
{
"helpers": {}
},
"resolveLanguageField"
]
},

Questions:
Why does `nodeByUri` return an internal server error after updating to WPML WPGraphQL 1.1.0?
How can I resolve the 'duplicate fields' error for the 'language' field on the 'page' type?

August 27, 2024 at 10:09 am #16108839

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

After discussing this issue with our developer, there is a patch file that helps you solve the internal error. Please download it here
hidden link

and replace it with the file in the folder wp-content/plugins/wpml-graphql/classes/Hooks/ObjectEntity/PostObject.php

And please notice that the query page by "nodeByUri" only works with the default language, not the second one.

Looking forward to your reply.
Thanks

The topic ‘[Closed] Queries using nodeByUri broken when using WPML GraphQL 1.1.0’ is closed to new replies.