Hey,
dunnow if this problem lies within contentful source plugin or in gatsby graphql but...
I have setup a content type called Person on contentful which has a field called sort_order which lets me sort persons...go figure.
So, running this query in the graphiql editor works fine...it returns the nodes in order.
allContentfulPerson(sort: {fields: sort_order}) {
edges {
node {
id
}
}
}
response:
{
"data": {
"allContentfulPerson": {
"edges": [
{
"node": {
"id": "c1hg38X3g6U8GU6WYyAiCyO"
}
},
{
"node": {
"id": "c5qkbSSBgzYuUcEw6qaOSmY"
}
},
{
"node": {
"id": "c4ZamiQP07eas6c2eKSu4MA"
}
},
{
"node": {
"id": "c5HcLEQSUPScemwkUqk6KGU"
}
},
{
"node": {
"id": "c488zNxYiNyMUUqeAAkCcIi"
}
}
]
}
}
}
but if i copy that query into a page...something like:
export const pageQuery = graphql`
query MedarbetarPageQuery {
allContentfulPerson(sort: { fields: sort_order }) {
edges {
node { ....etc
I get this error:
"Argument "sort" has invalid value {fields: "sort_order"}.鈫礗n field "fields": Expected type "ContentfulPersonConnectionSortByFieldsEnum", found "sort_order"."
Any ideas??
"gatsby-source-contentful": "1.3.7",
"gatsby": "1.8.4"
Fields is a list so the query should be [sort_order]. I don't know why GraphiQL isn't enforcing that. I've filed an issue there https://github.com/graphql/graphiql/issues/587
Thanks @KyleAMathews that worked like a charm...!! Agree that graphiql should have picked that up. Really getting used to copy/paste queries from graphiql to react components and they should work the same. Thanks again Kyle and great work with gatsby!!
Most helpful comment
Fields is a list so the query should be
[sort_order]. I don't know why GraphiQL isn't enforcing that. I've filed an issue there https://github.com/graphql/graphiql/issues/587