Designing a URL-based query syntax for GraphQL
Blog post from LogRocket
GraphQL's current syntax poses challenges for using HTTP caching, as it relies on persisted queries stored on the server, requiring complex nested queries to be encoded or reformatted for URL parameters, which are difficult for humans to read and write. To address this, an alternative syntax called PQL is proposed, enabling queries to be expressed in a single line that advances only forward in structure, eliminating the need for nesting and making it easier to compose queries directly in a browser's address bar. PQL introduces unique syntax features, such as bookmarks for path shortcuts and a different approach to defining fields and arguments, which allow for clearer, more readable single-line queries. Although PQL's syntax is not proposed as a replacement for GraphQL, it serves as an example of how the GraphQL over HTTP specification could evolve to improve human readability and usability.