New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graphql returning null when using Aliases #18802
Comments
A workaround that returns the expected data set looks like this: query RestaurantById($restaurantByIdId: ID!) {
restaurantById:restaurant_by_id(id: $restaurantByIdId) {
heroImage: hero_image {
id
}
imageGallery:image_gallery {
directusFilesId:directus_files_id {
id
}
}
}
restaurantHighlights:restaurant_by_id(id: $restaurantByIdId) {
menuHighlight:menu_highlight {
menuHighlightId:menu_highlight_id {
translations {
languages_code {
code
}
menu_item
}
}
}
}
} returning: {
"data": {
"restaurantById": {
"heroImage": {
"id": "f6d28bcd-eb9d-4020-8234-b5b4e8f91f02"
},
"imageGallery": [
{
"directusFilesId": {
"id": "a52584ff-26fe-4bd4-840d-6545edbc21bd"
}
},
{
"directusFilesId": {
"id": "816f87f6-df9d-4900-97f6-ad2b74a528d1"
}
},
{
"directusFilesId": {
"id": "31965deb-9387-4e82-8a66-03706d04908c"
}
}
]
},
"restaurantHighlights": {
"menuHighlight": [
{
"menuHighlightId": {
"translations": [
{
"languages_code": {
"code": "en-US"
},
"menu_item": "Steak Frites"
}
]
}
},
{
"menuHighlightId": {
"translations": [
{
"languages_code": {
"code": "en-US"
},
"menu_item": "Hamburger Parisien"
}
]
}
},
{
"menuHighlightId": {
"translations": [
{
"languages_code": {
"code": "en-US"
},
"menu_item": "Profiteroles"
}
]
}
}
]
}
}
} |
A snapshot can be sent if needed but it's a huge set! |
Can you verify that all queries that started return |
Apologies for the confusion, I've updated the original block. The duplication shouldn't have been there but the problem exists without the duplicated fields |
We had problems with the same bug and traced it down to this re-assignment. directus/api/src/utils/get-ast-from-query.ts Line 253 in 5c312f8
When called inside a nested field this will overwrite the I could provide a PR with a fix, if this helps getting this issue resolved? |
Describe the Bug
Fields can return null, depending on the ordering when using aliases. We are transforming the schema to use camelCase queries/fields/etc and when we do so, we often get null being returned for various fields. These tend to be fields where the data is nested several layers.
The following queries + responses should highlight this:
returns the following data:
Whereas unaliased query:
returns the following response:
To Reproduce
Directus Version
10.1.1
Hosting Strategy
Self-Hosted (Docker Image)
The text was updated successfully, but these errors were encountered: