irrigator

irrigator

Recently I’m learning GraphQL by reading Craft GraphQL APIs in Elixir with Absinthe. So far everything makes sense, but the overlapping of three data layers - GraphQL, Ecto and Database schemas - concerns me in some way. Surely they operate at relatively different levels, and keeping them separate adds a lot of flexibility to your system. But the cost is also pretty high. Not only are there much duplication among these three layers (type definitions and some business logic), you also need to think about putting which portion to which layer, if not implement it more than once. The most prominent example is validation.

The situation reminds of the Phoenix context, which also asks for a deep thinking about design. For those who are using GraphQL with Ecto, what’s your take on this?

Showing Posts 1 to 7

Qqwy

Qqwy

TypeCheck Core Team

This is a really good question, and I am also very interested in an answer. Exactly this issue (a seeming duplication between the GraphQL API and the database schemas) has prevented me from using GraphQL in my projects so far, because it seemed overkill most of the time, and I was a bit scared of trapping myself in a web of fake refactored duplication.

StefanHoutzager

StefanHoutzager

Maybe you can find a discussion on some of the problems you found here? Five Common Problems in GraphQL Apps (And How to Fix Them)

peerreynders

peerreynders

Phoenix contexts acknowledge that there are designs beyond CRUD. In CRUD applications the shape of the data in the page on the front end tends to dictate the shape of the data that is stored in the database. This is the hallmark of implementation coupling. Typically when you change something on one end that change ripples through to the other end (and any layers in between).

but the overlapping of three data layers - GraphQL, Ecto and Database schemas - concerns me in some way

That overlap may simply be a result of the technology being applied to an application with an “unsophisticated” domain - which wouldn’t be surprising if the entire point of the application is to clearly showcase how the technologies interact - without being obscured by complex application design concerns.

  • The shape of the data in the RDBMS is largely concerned with efficient and effective storage and retrieval of data the application typically uses - clearly the inserts, updates and queries influence the shape - but there may be optimization concerns to favour the performance characteristics of certain insert, update and query operations. That means that the capabilities of the RDBMS engine are going influence the shape of the data inside the database beyond the bare needs of the application.
  • Ecto brokers between the shape of the data needed by the application vs the shape of the data stored in the database. The shape of the data for the application is what you are primarily concerned with because that shape is influenced by the processing capabilities of the application.
  • GraphQL should be primarily concerned with the shape of the data that is needed by the client of the application (in the spirit of Consumer Driven Contracts). The application should typically hide certain implementation details from the client to stop the client becoming coupled to the implementation details of the application. Also the application could derive (aggregate) some information that doesn’t explicitly exist in the database for the purpose of exposing it to the client via GraphQL.
10
Post #3
BitGonzo

BitGonzo

Though I don’t have much to say on the subject myself, I have found this article to be an excellent read (quite comprehensive of an overview):

Will be interesting to see how things develop.

The biggest oddity I notice in the “GraphQL vs REST” conversation, is the falsehood that you must pick one.

In a world of SoA, you are likely to have multiple services, which expose multiple APIs. In the RPC vs REST article I point out that some services might be REST and some might be RPC, and you can absolutely throw some GraphQL in with your REST.

One mix of REST and GraphQL could just be adding a /graphql endpoint to api.whatever.com and having that as your GraphQL endpoint on an REST API.

Another, is one that has been vaguely tossed around at work, which is the idea of having one GraphQL API, acting as a gateway to our other multiple REST APIs.

Having one GraphQL server act as a sort of data proxy, giving one entry point for mixed data, one Authentication scheme despite each REST API having its own “unique” approach to tokens, one HTTP call for clients - despite it hitting multiple actual REST APIs, etc., would be a damn powerful thing.

mkunikow

mkunikow

I am wondering is there the same problem with https://www.apollographql.com ?
So I assume will be the best have some sort of distributed database with GraphQL functionality …
or GraphQL hosted as service … something like https://firebase.google.com/

Edited
I think there will be the same problem with apollo.
https://github.com/serverless/serverless-graphql

So in this case I prefer hosted service like firebase :slight_smile:

I see another option

Deploy Neo4j backed GraphQL APIs based on your custom GraphQL schema.

https://www.npmjs.com/package/neo4j-graphql-cli

https://dzone.com/articles/graphql-meets-graph-database-a-graphql-neo4j-integ

OvermindDL1

OvermindDL1

What I think would be best for graphql projects is just have the database, have a graphql layer, and have both the API and Web Controllers access the GraphQL layer (so Controllers just call into the local GraphQL bit), that way it all goes through a single defined point that handles auth and all. :slight_smile:

mkunikow

mkunikow

Yes I totally agree.
I have some hopes for Neo4j-GraphQL project or some cloud providers that would distribute it as service , maybe as competitor to google firebase.

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 94592 917
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
AstonJ
Since we have deprecated our Erlang sections (as we have dedicated Erlang Forums now) let’s add this thread for those who’d like to post ...
New
maennchen
:warning: Security advisory: Decimal DoS vulnerability A vulnerability has been published for decimal where very large exponents can cau...
New
Null-logic-0
What IDE or editor are you using for Elixir development? Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New

Other Trending Topics Top

marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews