Filtering API: REST APIs with Some of GraphQL's Conveniences
summary
Shows how to add a query-string DSL to REST endpoints so clients can filter (eq, like, <, <=, >, >=, between), sort, paginate (limit/offset) and select fields without changing controllers. Presents a custom single-method PHP class that parses those operators and returns JSON, and also demonstrates using Spatie Query Builder with Eloquent for the same configurable, extensible behavior while noting the need for validation and careful placement to avoid surprising query semantics.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 3:18Talk context
- 4:47REST filtering problems
- 6:35Laravel Query Builder demo
- 10:59Custom filtering class
- 13:58Testing custom class
- 18:31Eloquent Query Builder integration
- 20:21Eloquent models and filters demo
- 26:08Spatie Query Builder advanced ops
- 29:35Configuration troubleshooting
- 31:27Q&A: Multi-sort
- 34:57Q&A: GraphQL similarities
- 36:47Q&A: Model vs controller logic
- 38:00Summary
related talks
42mPerformant APIs with GraphQL and PHP
50mGraphQL is right in front of us, let's do it, with Symfony
33mGraphQL Will Do To REST What JSON Did To XML
46mIntroduction to GraphQL
32mTradeoffs between leveraging FHIR REST APIs vs. GraphQL APIs
41mBuilding first-class REST APIs with Symfony
53mGraphQL: Improvements You Can Make Today
58mGraphQL -- Flexible APIs for Adaptive Clients
