You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorting based on field raises a GraphQL Error error
Steps to reproduce
Using http://localhost:8000/__graphql I can run the following query:
{
allMarkdownRemark {
edges {
node {
fields {
title
type
slug
date
author
category
}
}
}
}
}
Which shows me all my nodes with all fields populated. However if I try and sort based on any of these fields, for example on date:
{
allMarkdownRemark(
sort: { fields: [date], order: DESC }
) {
edges {
node {
fields {
title
type
slug
date
author
category
}
}
}
}
}
Expected result
I would expect the query to return the results sorted by date.
Actual result
GraphQL Error Argument "sort" has invalid value {fields: [date], order: DESC}.
In field "fields": In element #0: Expected type "MarkdownRemarkConnectionSortByFieldsEnum", found date.
Notes
My understanding is that these fields should be added dynamically and that I should be able to sort on them. Trying to filter on any field results in the same error. I am only able to sort on markdown fields. These issues suggest this should be possible #2886#2024.
Yeah, it's invalid but it's understandable (double use of fields word) - fields input param is to specify path to field in note that is used for sorting and isn't actually tied to node.field - so if path is node.field.something, we need to use field___something. If path would node.date, then we would use just date.
Description
Sorting based on field raises a GraphQL Error error
Steps to reproduce
Using
http://localhost:8000/__graphql
I can run the following query:Which shows me all my nodes with all fields populated. However if I try and sort based on any of these fields, for example on
date
:Expected result
I would expect the query to return the results sorted by date.
Actual result
Notes
My understanding is that these fields should be added dynamically and that I should be able to sort on them. Trying to filter on any field results in the same error. I am only able to sort on markdown fields. These issues suggest this should be possible #2886 #2024.
Environment
File contents (if changed)
gatsby-config.js
: N/Apackage.json
: N/Agatsby-node.js
: N/Agatsby-browser.js
: N/Agatsby-ssr.js
: N/AThe text was updated successfully, but these errors were encountered: