-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better GraphQL Integration #44
Comments
Hey there, Thank you for the suggestions and feedback (I am missing this the most in this project 😄 ) I think you raised some very good and interesting points.
All your points make sense to me. I cannot see anything in the moment I would disagree with. Unfortunately, I can't give a timeline for this as it is a significant effort. |
I too would like a graphql design like above. Found it confusing in graphiql even with the docs there to help. Normally the graphiql docs are all you need to learn the api but I agree the underlying database abstraction has leaked too much into graphql. It does seem like a big effort to change but I'd be willing to help. I wonder if a shortcut could be compiling graphql queries to EQL? Although I haven't yet looked in the code to see how you're doing it. Just want to spark a line of enquiry 😄 |
Since we are all interested in this, let's actually help out by writing some pull requests to fix this step by step. :) |
Not sure where to start though... |
I've looked a bit more into this. Here are my current thoughts. In general I am careful with hiding knowledge because it means you have to make default assumptions. Basically for every piece of knowledge you hide, you will need to make a one-fits-all choice. The balance is between readability/easy of use and potential performance issues/unexpected behavior. In this case, I can see the point of adding a simple interface for "simple" cases and leave the more complex option for the rest. So the query in point 1. can already be done currently:
I would agree that this query can be hard to read so I've added some "syntactical sugar" (in 1.3.0) to make it more palatable for basic scenarios. Semantically the following is equivalent to the query above.
The main difference to the example presented in point 1. is that the operators "in" or "eq" do not exist explicitly. I think the current filtering is powerful enough for the vast majority of cases. If it becomes necessary to do some more advanced calculations or do type specific operations when filtering selection sets then another directive could be added in the future. Part of the suggestion in point 2 is already implemented in EliasDB - I just failed to document it 😄 - EliasDB supports "Fragments" of the GraphQL standard together with the Although it is not possible to define interfaces as such, it is possible to use fragments with their type condition matching on node kinds. For example in the tutorial I could write:
I can also use variables in combination with a directive to modify a query based on input parameters:
Interface and Unions are part of the GraphQL Type system which is not implemented in EliasDB. In the moment I am not sure that implementing this would add enough value to EliasDB to justify the significant effort. BTW re: where stuff is: The GraphQL parser can be found here: https://github.com/krotik/common/tree/master/lang/graphql/parser |
Hi @krotik!
EliasDB looks very promising to become a one-stop GraphQL-DB solution.
However, I think there are some points that could increase the current experience tremendously:
1. Better GraphQL API
For this, you might want to look at how Dgraph handles their GraphQL API.
The API should hide as much backend/query knowledge from the frontend-user as possible. Currently, when using GraphQL, the frontend developer has to have domain knowledge on eliasdb specific syntax like traversal arguments.
Most clients do not care about such power. They want to do the following:
Thats pretty much all IMHO. More complex operations could of course be still available, but maybe optional.
Example GraphQL query:
The above query is 100% human readable and the client does not need to care about how the underlying DB traverses the graph.
2. Interface/Union Support
Interfaces and Unions are defined on the GraphQL standard. They are important as they reduce query complexity and boilerplate.
Example Query:
3. Bonus Points: Create Database From GraphQL Schema:
Again, this example comes from how dgraph handle things.
Given a GraphQL type schema, eliasdb could bootstrap its whole CRUD-API:
Using the above Info you could completely bootstrap and layout an EliasDB instance and generate a GraphQL CRUD API as described as in 1.
Why not use Dgraph after all? Good Question. Here are the answers:
But, Dgraph has made a lot of things right and was very close in becoming the GraphQL-DB no-code solution. So we could borrow a lot of concepts to make EliasDB better in that regard.
Happy to hear your thoughts about this!
The text was updated successfully, but these errors were encountered: