Graphql-Up: CLI to create a ready-to-use GraphQL API
graph.cool
graph.cool
A good place to start reading is http://graphql.org/ .
Would love to see Schema Definitions land in GraphQL proper btw :-)
These last 2 years, a lot of my clients have been asking me, "Should we switch to React/GraphQL?" And I've done one big project with GraphQL, in the spring of 2016. And I was amazed at how much I had to hand code, especially compared to Ruby On Rails.
In 2004, Ruby On Rails was born with these kinds of CLI tools. Indeed, Ruby On Rails pretty much established our modern ideas of how much a framework should do for us.
A CLI for GraphQL certainly makes the React eco-system more competitive with Ruby On Rails, but I am astonished that it took this long.
(PS: I am aware that React and Ruby On Rails are not strictly competitors, since you can use them together to create software/website. Nevertheless, "Should we use Ruby On Rails or React?" is a real question that I've been asked several times over the last few years.)
I think it is fair to say that React and RoR are serving the same needs. Obviously the two approaches are very different, mainly because they are from different eras.
In many ways RoR is still ahead compared to React, and ease of getting started + tooling like you mention is one of them.
Expo and create-react-app is making good progress towards making this more seamless and we hope graphql-up with time will be able to solve the last missing piece, namely schema generation and migrations.
If you'd like to chat about RoR vs React/GraphQL and especially wider adoption by agencies and companies my email is soren@graph.cool. Also - let me know if you are going to GraphQL Europe[1] - I'd love to meet.
Whoever asked that "real" question is confused. They're orthogonal.
Literally almost every app I ever write, even the simple ones, offload tons of work to the database for joins between a half dozen tables.
I have yet to see a sane answer on how this is possible with GraphQL? How am I supposed to think about performance ... and not just having something overly simple/basic like HERES MAH BLOG... HERES DA COMMENTS!!!!!!
A GraphQL query is just a query on some objects having some fields. You can tie any function to a field. In particular, you can have each field be a function which executes SQL code. And that code is free to JOIN as it wants.
Squint your eyes some more: how do you do it in a RESTful interface? It is the same idea.
GraphQL really excels, however, in that it is not tied to SQL. You can have part of the query be from one source, and other parts be from other sources.
- Ruby implementation can dig into Active Record to perform batching of the queries, that normally would be executed in parallel.
- JavaScript implementation may use DataLoader library to support the same batching behavior for basically any async (promise-based) operation. See this presentation, it shows how the issue look like and how Data Loader helps to solve it: https://www.youtube.com/watch?v=c35bj1AT3X8&t=15m42s
- Python and Elixir implementations can make use of information about query subsegments, so you can prefetch necessary data.
- F# implementation works in similar way to Elixir but it's not limited to analyse GraphQL query fragments, but can also perform live analysis of the user-defined resolve functions code to determine a tree of used F# objects and properties instead. This allow to diverge GraphQL domain model from the underlying database model.
- A lot of other libraries are dedicated to particular database or query language and map GraphQL schema directly onto database model, so GQL query is translated directly into underlying database query model (including joins).
So asking how to do a join in GraphQL is like asking how to do a join in REST. It's not a well-formed question.
The good news is that the sever can expose absolutely anything as a GraphQL query. They're just arbitrary entry-points into the schema. Think of it as like calling a stored procedure. The procedure is an opaque thing as far as the caller is concerned.
PS: My comment does not mean the reference implementation is bad, it's just that it's a reference and good in a lot of cases but not in all. It does not mean you have to use every part of it, you can write your own execution module.
There are already some other tools that will give you a GraphQL API in very little code, but the fact that this one is hosted means you can host a frontend on GitHub pages or something, send it to your friends, and have a basic app going.
Definitively bookmarked!
its $45 for 2GB + 10m requests, and $449 for 10GB + 50m requests. (more expensive per GB or requests..)
Is there an easy way to eject into a full blown graph.cool app? It seems you can't take any of your schema and use it as a starting point in graph.cool. From a business perspective, wouldn't that be the point? Perhaps I'm missing something though.
To your question (Graphcool co-founder) - Our vision for graphql-up is twofold:
1) Enable you to easily spin up a fresh GraphQL endpoint in your automated tooling. Think ci test servers.
2) Lower the barrier for people new to GraphQL.
I'm especially excited about the second point and looking forward to see how the community will leverage graphql-up to make tutorials and documentation more accessible
Basically I'm trying to understand how far this takes you and what "up" is missing in comparison to the information you provide to your core product, "cool," to produce schemas. It would be very enticing if you said there is a 1-step solution to graduate your graphql-up server to a full blown graph.cool app. Are there really no useful synergies there? Is it a secret lol?
I think you are right that it could be useful to be able to import a graphql-up api to graphcool, so that is definitely something we will consider. What we will do for sure is allow you to create a Graphcool project based on a Schema Definition, just like with graphql-up - look for that in the near future.
Btw cool idea! :)
Graphcool automatically generates a crud style api based on your schema, so you don't have to specify mutations in the schema.
We'll add the ability to auto-generate mock data, but for now you will have to use mutations to insert some data
I've just created a Github issue for that. Please feel free to add a comment: https://github.com/graphcool/graphql-up/issues/2