bradleyboy / tuql

Automatically create a GraphQL server from a SQLite database or a SQL file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Filtering

stereokai opened this issue · comments

Hi, first of all just want to say this is an amazing tool, it's really just too cool :P

Especially because I understand that tuql generates the GraphQL schema automatically from the sqlite DB. But does it mean that that is the reason why the it's impossible to use GraphQL filter? Because I'm getting this issue trying to use it:

{
  "errors": [
    {
      "message": "Unknown argument \"filter\" on field \"events\" of type \"Query\".",
      "locations": [
        {
          "line": 35,
          "column": 10
        }
      ]
    }
  ]
}

For this query:

{
  events(filter: { userInfoType: 0 }) {
  	userInfoLog
  }
}

In addition, I tried to use where , which is available, with OR syntax:

{	
 events( where: { OR: [{userInfoType: 0}, {userInfoType: 1}]}) {
  userInfoLog
}
}

But then I'm getting the following error, even though 0 is a valid value for UserInfo_Type in the DB:

{
  "errors": [
    {
      "message": "Invalid value { UserInfo_Type: 0 }",
      "locations": [
        {
          "line": 35,
          "column": 2
        }
      ],
      "path": [
        "events"
      ]
    }
  ],
  "data": {
    "events": null
  }
}

I am new to GraphQL. Am I doing something wrong?

I found where I was wrong. The querying sequence is based on Sequalize, so it should be:

{	
 events( where: { or: [{ userInfoType:0 }, { userInfoType:1 }] }) {
  userInfoLog
}
}

(or in lower case, from Op.or in Sequalize)