cofacts / rumors-db

Scripts for managing rumors db
MIT License
5 stars 11 forks source link

Some articles are having null createdAt #34

Open MrOrz opened 5 years ago

MrOrz commented 5 years ago

Null values will cause errors in ListArticle query. For example, the last cursor returned by this query is broken by null:

{
 ListArticles(orderBy:{createdAt:DESC}, filter:{replyCount:{GT:0}}, first:50, after:"WzE0ODE4ODk2MDAwMDAsIjUzNTg1NDY2MDEwMTUtcnVtb3IiXQ==") {
      pageInfo {
        firstCursor
        lastCursor
      }
      edges {
        cursor
        node {
          id
        }
      }
    }
}

When the broken cursor is used, it will cause error.

Query:

{
 ListArticles(orderBy:{createdAt:DESC}, filter:{replyCount:{GT:0}}, first:50, after:"Wy05MjIzMzcyMDM2ODU0Nzc2MDAwLCIwNmRiMTAxMTE3ZTFlYjgyYzE4MjI0MTA0YmQwYTgxYS1ydW1vciJd") {
      pageInfo {
        firstCursor
        lastCursor
      }
      edges {
        cursor
        node {
          id
        }
      }
    }
}

Result:

{
  "data": {
    "ListArticles": {
      "pageInfo": {
        "firstCursor": null,
        "lastCursor": null
      },
      "edges": null
    }
  },
  "errors": [
    {
      "message": "[illegal_state_exception] No matching token for number_type [BIG_INTEGER]",
      "locations": [
        {
          "line": 4,
          "column": 9
        }
      ],
      "path": [
        "ListArticles",
        "pageInfo",
        "firstCursor"
      ],
      "authError": false
    },
    {
      "message": "[illegal_state_exception] No matching token for number_type [BIG_INTEGER]",
      "locations": [
        {
          "line": 5,
          "column": 9
        }
      ],
      "path": [
        "ListArticles",
        "pageInfo",
        "lastCursor"
      ],
      "authError": false
    },
    {
      "message": "[illegal_state_exception] No matching token for number_type [BIG_INTEGER]",
      "locations": [
        {
          "line": 7,
          "column": 7
        }
      ],
      "path": [
        "ListArticles",
        "edges"
      ],
      "authError": false
    }
  ]
}

We should either handle null or properly fill in missing values so that elasticsearch don't generate broken cursors.