Skip to content

Conversation

@fzaninotto
Copy link
Member

@fzaninotto fzaninotto commented Jul 27, 2017

  • Generate filter type for entities
  • Make filters work
  • Fix tests
  • Document it

The filter logic was implemented in the resolvers, but not declared in the type system - so it was unusable.

Now, for every type, we add a filter type.

e.g.

type Post {
  id: ID!
  title: String!
  nb_views: Int
}
type PostFilter {
  q: String
  id: ID
  title: String
  nb_views: Int
}

I also modified the type of the filter parameter to match the related filter type:

type Query {
  allPosts(filter: PostFilter): [Post]
}

And now the filter system works:

{
  allCustomers(filter: { first_name: "Agnes" }) {
    first_name
    last_name
  }
}
{
  "data": {
    "allCustomers": [
      {
        "first_name": "Agnes",
        "last_name": "Mathis"
      },
      {
        "first_name": "Agnes",
        "last_name": "Tucker"
      },
      {
        "first_name": "Agnes",
        "last_name": "Pope"
      }
    ]
  }
}

@fzaninotto fzaninotto changed the title [WIP] Add filters to all* queries [RFR] Add filters to all* queries Jul 30, 2017
@fzaninotto
Copy link
Member Author

Switching to RFR

@djhi djhi merged commit fbeccf5 into master Jul 31, 2017
@djhi djhi deleted the filter_type branch July 31, 2017 12:41
alexisjanvier added a commit that referenced this pull request Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants