Skip to content

Instantly share code, notes, and snippets.

@tmcgann
Last active January 29, 2020 20:07
Show Gist options
  • Save tmcgann/9d2ef4c8a0008a16a7ca7333df55aedc to your computer and use it in GitHub Desktop.
Save tmcgann/9d2ef4c8a0008a16a7ca7333df55aedc to your computer and use it in GitHub Desktop.

Query Proposal

Pagination

Offset

Possible keys:

  • offset: Int
  • limit: Int
{ "limit": 100 }
{ "offset": 10, "limit": 100 }

Sorting

Possible keys:

  • orderBy
    • Field: SortOrder
{ "id": "desc" }
[{ "id": "desc" }, { "author": "ascNullsFirst" }]

Possible sort orders:

  • "asc"
  • "ascNullsFirst"
  • "desc"
  • "descNullsFirst"

Filtering

Possible keys:

  • condition(s)
  • filter(s)
  • where
{ "<fieldName>" : { "<operator>": "<value>" }

Possible operators:

  • _eq
  • _neq
  • _in
  • _nin
  • _gt
  • _lt
  • _gte
  • _lte
  • _contains
  • _ncontains
  • _and
  • _or

Request Examples

{
  "limit": 100,
  "offset": 500,
  "orderBy": [{ "name": "asc" }],
  "condition": {
    "firstName": { "_eq": "Taylor" },
    "lastName": { "_neq": "McGann" },
    "_or": [
      { "age": { "_lt": 40 }},
      { "age": { "_gte": 30 }}
    ]
  },
  "commit": <Commit>
}

Response Examples

Possible limit-offset response:

{
  "headers": [...],
  "rows": [...],
  "pageInfo": {
    "offset": <Int>,
    "limit": <Int>,
    "totalCount": <Int>,
    "currentCommit": <Commit>,
    "headCommit": <Commit>
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment