I thougt that UIDs were unique, but they aren't:
query MyQuery {
pages: entries(site: ["mySiteDe", "mySiteEn"], section: "pages") {
id
uid
language
siteId
}
}
returns
{
"data": {
"pages": [
{
"id": "17",
"uid": "80527c9a-ab27-4201-b34e-619b51731d5a",
"language": "en",
"siteId": 1
},
{
"id": "17",
"uid": "80527c9a-ab27-4201-b34e-619b51731d5a",
"language": "de",
"siteId": 2
}
]
}
}
These are two different records (one in english, one in german), but they have the same UID. Using popular GraphQL frontend libraries like Apollo or Urql would break since they rely on really unique IDs.
That鈥檚 the _entry鈥檚_ UID, and there鈥檚 only one entry here, which encompasses any site-specific data.
We could add a new siteSettingsId and siteSettingsUid fields, for pulling in the entry鈥檚 site-specific ID and UID from the elements_sites table.
@andris-sevcenko elements are already queried with the siteSettingsId, so that should be easy to add. I don鈥檛 think it鈥檚 a good idea to pull in the UID by default though, so if the siteSettingsUid field is included, it would need to be explicitly added to the element query:
$elementQuery->addSelect(['siteSettingsUid' => 'elements_sites.uid']);
Sounds good. Any unique param (across all sites) would be really helpful.
We could build an own one with a combi ation of siteId + uid, but a built-in solution would be nice.
If there were a site-wide UID, it would also be great to get an entry with this ID without the need to specify a site.
Are there any plans to make the GraphQL API Relay-compatible in the future?
@gopeter FWIW, most frameworks provide ways to combine keys from multiple fields, but I agree it's not always going to be possible.
I also understand that it's a bit pointless to provide a unique identifier and not provide a way to fetch the content using that identifier.
We'll talk this over internally and we'll get a solution for you.
We鈥檝e just added a new siteSettingsId argument + field to all element types, which refers to elements鈥檚 IDs in the elements_sites table, which will always be unique.
Most helpful comment
We鈥檝e just added a new
siteSettingsIdargument + field to all element types, which refers to elements鈥檚 IDs in theelements_sitestable, which will always be unique.