Hey guys, just starting out on graphcool and I’m t...
# prisma-whats-new
a
Hey guys, just starting out on graphcool and I’m trying to fetch certain nodes of a specific type. for example I am sending
Copy code
query {
  allAnswers(filter: {
    keywords_contains: "location"
  }) {
    response
  }
}
This is an example of the Type in the schema
Copy code
type Answer @model {
  id: ID! @isUnique
  intent: String!
  keywords: [String!]
  response: String!
  subject: String! @isUnique
  timeStamp: DateTime!
}
and I am getting this error
Copy code
{
  "data": null,
  "errors": [
    {
      "message": "Argument 'filter' expected type 'AnswerFilter' but got: {keywords_contains: \"location\"}. Reason: 'keywords_contains' Field 'keywords_contains' is not defined in the input type 'AnswerFilter'. (line 2, column 22):\n  allAnswers(filter: {\n                     ^\n (line 3, column 5):\n    keywords_contains: \"location\"\n    ^",
      "locations": [
        {
          "line": 2,
          "column": 22
        },
        {
          "line": 3,
          "column": 5
        }
      ]
    }
  ]
}
can someone point out where I am going wrong.
filter works with subject, so specifically we need to be able to filter an array type.
i
If you check out the “Schema” tab on the right in the Playground, you can go see all of your filter options
Sorry, I read this pretty fast… You can’t filter on arrays
However, if you made “Keywords” an Enum, you could filter based off of that
Not the best solution. I’m not sure what the goal of that field is so this may not be a plausible solution. (IE: Keywords can be anything the user puts in as arguments to the mutation, and could get out of control. If it were only a small amount of keywords shared across each Answer, then this would be more plausible.)
This is also true of subscription filters too
n
hey @amanda_hogan, scalar lists don't have filters yet. here's a proposal for better scalar list support: https://github.com/graphcool/framework/issues/1275
until that's implemented, here's an approach using relations/models instead of scalar lists, that allows you to use filters in this case: https://github.com/graphcool/framework/issues/60#issuecomment-342132472