Skip to content
Developerhome

Ordered list

  Less than to read

The query supports ordering using the orderBy option.

For orderBy to work, you need to list the fields to be sorted. You can use the keyword:+1 option to sort in ascending order and the keyword:-1 option to sort in descending order.

You can have several sorting criteria and sort properties located in a linked node.

The following table displays examples and results of using an ordered list. Some of the fields displayed are not mandatory and others have been omitted.

{ 
    xtremMasterData { 
        item { 
            query(orderBy: "{name:+1}") { 
                edges { 
                    node { 
                        id 
                        name 
                    } 
                }
            } 
        } 
    } 
}
{ 
    "data": { 
        "xtremMasterData": { 
            "item": { 
                "query": { 
                    "edges": [ 
                        { 
                            "node": { 
                                "id": "66W018NF", 
                                "name": 03 Nylon Flat" 
                            } 
                        }, 
                        { 
                            "node": { 
                                "id": "66W10F-14", 
                                "name": "FLAT WASHER 7/16" 
                                } 
                        }, 
                    ]
                }
            }
        }
    }
}
{ 
    xtremMasterData { 
        item { 
            query(orderBy: "{currency:{name:-1},name:+1}") { 
                edges { 
                    node { 
                        id
                        name 
                        currency{ 
                            name 
                        } 
                    } 
                } 
            } 
        } 
    }
} 
{ 
    "data": { 
        "xtremMasterData": { 
            "item": { 
                "query": { 
                    "edges": [ 
                        { 
                            "node": { 
                                "id": "66W018NF", 
                                "name": "03 Nylon Flat", 
                                "currency": { 
                                    "name": "US Dollar" 
                                } 
                            } 
                        }, 
                        {
                            "node": { 
                                "id": "66W10F-14", 
                                "name": "FLAT WASHER 7/16", 
                                "currency": { 
                                    "name": "US Dollar" 
                                } 
                            } 
                        },
                    ]
                }
            }
        }
    }
}