-
We've seen users asking for recommendations and options for putting a GraphQL API layer in front of Materialize. I'm using this Q&A post to centralize and track the current state of GraphQL on Materialize. If I wanted to query Materialize via GraphQL, what are my options? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
There are several approaches to this that each come with trade-offs which I'll attempt to call out so that you can look at your specific requirements and decide on a solution that aligns with your needs. Option One: Custom Node.js ServiceIf you're only serving very specific GraphQL queries, it might be ideal to write your own API service in Node that takes full advantage of the streaming TAIL features of Materialize. 📖 Example Reference: The App script in this real-time demo app 👍Pros: Full control over how Materialize is queried. Ability to subscribe to updates to a view and use GraphQL streaming to stream updates to the client. Option Two: Postgraphile (with hacks)If you're already using Postgraphile, or you don't want to write your own postgraphile is the most popular "graphql on postgres" framework. There is a three-step "hack" to make Materialize work with Postgraphile:
👍Pros: Ideal if you're already running Postgraphile. Postgraphile provides a rich set of GraphQL features and integrations Option Three: Cube.js GraphQL APICube.js is a "headless BI" service that provides, among other things, a GraphQL API to schemas you define on top of Materialize. 📖 Example Reference: The Demo in Cube.js repo 👍Pros: Comes with additional features like authentication. Also works via Cube Cloud |
Beta Was this translation helpful? Give feedback.
There are several approaches to this that each come with trade-offs which I'll attempt to call out so that you can look at your specific requirements and decide on a solution that aligns with your needs.
Option One: Custom Node.js Service
If you're only serving very specific GraphQL queries, it might be ideal to write your own API service in Node that takes full advantage of the streaming TAIL features of Materialize.
📖 Example Reference: The App script in this real-time demo app
👍Pros: Full control over how Materialize is queried. Ability to subscribe to updates to a view and use GraphQL streaming to stream updates to the client.
👎Cons: Doesn't scale well if you need to handle a truly di…