Skip to content
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

Support Facebook's GraphQL #3711

Open
pilwon opened this issue Feb 2, 2015 · 126 comments
Open

Support Facebook's GraphQL #3711

pilwon opened this issue Feb 2, 2015 · 126 comments
Milestone

Comments

@pilwon
Copy link

@pilwon pilwon commented Feb 2, 2015

Facebook announced GraphQL (w/ Relay) at the React Conf '15 and the open spec will be released in the near future. It is a great idea that is not specific to React/Relay.

It could be a powerful native add-on to RethinkDB providing an alternative, efficient way to construct complex, nested queries from multiple tables in a single query. (r.graphql(STATEMENT))

It will also be an opportunity for potentially bringing a lot of (fast-growing) React users, especially when it is combined with the power of recently announced real-time changefeed feature.


Update (8/13/2015):

GraphQL
Relay
@danielmewes danielmewes added this to the backlog milestone Feb 2, 2015
@danielmewes

This comment has been minimized.

Copy link
Member

@danielmewes danielmewes commented Feb 2, 2015

Hi @pilwon, that's an interesting suggestion.

I think we're going to concentrate on ReQL for the time being (and possibly add graph features, see #3142), but embedding another query language will eventually become an interesting option.

I wonder if we could add RethinkDB support to React independently of supporting GraphQL. That would be one for @deontologician , I haven't looked into it at all yet.
Another option might be a client-side "wrapper" library that translates GraphQL queries into ReQL.

@Agamennon

This comment has been minimized.

Copy link

@Agamennon Agamennon commented Jun 5, 2015

GraphQL would be enormous boost to rethinkdb adoption, if it could be done close to release it will be the best db option for anyone using Facebook stack, and that mind-share is big and going fast

@thejsj

This comment has been minimized.

Copy link
Collaborator

@thejsj thejsj commented Jun 5, 2015

@pilwon, @Agamennon Isn't what you really want an adapter for GraphQL that sits on top of RethinkDB? Would this be a project be outside the scope of the database? You can't, for example, query RethinkDB from the client (and you probably don't want to either) and GraphQL would always be queried from the client.

@pilwon

This comment has been minimized.

Copy link
Author

@pilwon pilwon commented Jun 5, 2015

@thejsj An adapter transforming GraphQL into ReQL statement is definitely one way, but more preferred approach I hope to see is a new r.graphql(<statement>) that can receive raw GraphQL statement and internally process and return back most optimized results so the web server can simply forward them to the client. Added benefit with this approach is you only implement GraphQL once in the database engine itself and all RethinkDB client libraries will benefit from any subsequent updates without code updates. (no need to create and update adapter for every language RethinkDB client library supports)

As @Agamennon also mentioned above, this single feature implementation can potentially bring massive number of React developers and instantly turn RethinkDB into a de-facto standard database for React applications. Imagine how the community will react when rethinkdb also supports changefeed.

This single endpoint approach really seems taking off right now. There's also a promising project called falcon by Netflix trying to solve a similar problem. I think jumping into this early will help RethinkDB stay ahead of the game and win over its competitors easily.

@jbroadway

This comment has been minimized.

Copy link

@jbroadway jbroadway commented Jul 2, 2015

Facebook just posted their GraphQL reference implementation. It would be really cool to see a GraphQL to RethinkDB layer, or a RethinkDB mixin for React like Firebase has with ReactFire.

@marshall007

This comment has been minimized.

Copy link
Contributor

@marshall007 marshall007 commented Jul 3, 2015

After skimming through the draft specification it appears as though GraphQL relies pretty heavily upon schema definitions through its own type system in order to validate queries and to support reflection. As a result, I don't think RQL itself could support a term like r.graphql(<statement>) because the statement needs to be interpreted in the context of application-specific types.

However, as @danielmewes mentioned, it would probably be possible to implement this as a wrapper around RQL (similar to thinky) which could be made aware of user-defined schemas.

@divmain

This comment has been minimized.

Copy link

@divmain divmain commented Jul 4, 2015

I saw this added the other day, might be similar to what you're looking for @jbroadway.
https://github.com/mikemintz/react-rethinkdb

@jbroadway

This comment has been minimized.

Copy link

@jbroadway jbroadway commented Jul 4, 2015

Thanks @divmain! Just saw that pop up on Hacker News this morning.

@Agamennon

This comment has been minimized.

Copy link

@Agamennon Agamennon commented Jul 8, 2015

So this is what Facebook is selling, you have a relay store that talks to a Graphql server, relay assembles the query to the Graphql server that can answer that request accordingly, now why do i believe rethink could profit from this? my answer is two fold:

1: Graphql on its own, is a much better way to query data from the server then thinking about the exact structure of how the data is stored on the server, in practice you never use tables or other "sql like" abstractions, what you want is just a specific Json, so Graphql on its own, even when not coupled with Ralay or other React fluff, stands on its own.

2: By having an internal implementation of Graphql, Rethinkdb could optimize and do other stuff that drivers would need to do, and do that inside the server without back and forth information being exchanged with a potential rethink-graphql server driver, and they can only do that by inferring on the structure of the user data, and requiring the user to probably provide some mappings (this last part might be inevitable)

So, IMHO, Graphql should be taken seriously! rethinkdb would profit tremendously, as querying data from it would be intuitive to web developers, the old ways of writing backed code is over, rest or rpc specific code, is probably going to be obsolete, lets adjust accordingly.

@geddski

This comment has been minimized.

Copy link

@geddski geddski commented Jul 24, 2015

GraphQL does sound promising. I think it would be premature though to bake in support for it (if that were even possible) into RethinkDB. A solid adapter would probably be awesome enough.

@contra

This comment has been minimized.

Copy link

@contra contra commented Aug 12, 2015

@geddski Got any pointers on where somebody implementing an adapter should start?

@andrerpena

This comment has been minimized.

Copy link

@andrerpena andrerpena commented Aug 12, 2015

Facebook has just released Relay: https://github.com/facebook/relay

@geddski

This comment has been minimized.

Copy link

@geddski geddski commented Aug 12, 2015

@contra I'm looking into the same question currently.

@rattrayalex

This comment has been minimized.

Copy link

@rattrayalex rattrayalex commented Aug 13, 2015

As basically "a random member of the React community", I'm seeing a lot of shops switching (actively, soon, or planned) from Angular/whatever to React. I myself recently did a big switch from Angular to React and the results are just great. Going straight to Relay as well at the same time would be a massive win, the problem is that there aren't any GraphQL implementations out yet.

RethinkDB seems poised to be a top candidate to support it faster and better than any others, since it's already so much closer to what the client is asking for than, say, PGSQL (which would otherwise be my first choice).

While a community adapter is a totally sane approach to this, and in fact I nebulously hope to experiment with building one myself, native official support from the RethinkDB team could really push things over the edge for a lot of teams who are starting out or rewriting and want to be building with best-of-breed technologies.

tl;dr, I agree with @Agamennon that official support for GraphQL could lead to a big growth boost for RDB, though a community adapter would be "fine" too.

@coffeemug

This comment has been minimized.

Copy link
Contributor

@coffeemug coffeemug commented Aug 13, 2015

Cofounder @ Rethink here. Firstly, a disclaimer: I haven't programmed in React beyond doing a very simple toy project, so there's a possibility I'm going to say something stupid.

From a technical perspective I think there are a few ways of doing this:

  1. An r.graphql command. GraphQL does seem to depend on the schema to evaluate queries, but I don't think it's a problem. The command could just take a schema, and we could cache it in the db to avoid the performance hit of the user sending it every time.
    • Pros: one implementation to rule all them languages; efficient
    • Cons: server team is currently resource constrained (tons of users/customers want very different things); users still need to build a backend; baking a very new tech into db is risky
  2. Rethink's HTTP server could support GraphQL queries directly (potentially built on top of r.graphql)
    • Pros: you can build react apps without building a backend at all; this would be frakkin' awesome
    • Cons: we'd have to solve security, which is hard
  3. Ship it as an adapter on top of RethinkDB via a language library
    • Pros: probably quite easy to write a GraphQL->ReQL adapter
    • Cons: We'd start in JS, but what about all the other languages?
  4. Ship it as an adapter on top of RethinkDB via a proxy project (possibly on top of a language library)
    • Pros: also easy to do; you don't need a backend; security is easier
    • Cons: not as nice a user experience; worse from the marketing POV

I think this is super-important and we've got some serious decisions to make. The team is going rafting tomorrow to celebrate the Raft release 😁 but I'll see if we can carve out some time and discuss this ASAP.

@pilwon

This comment has been minimized.

Copy link
Author

@pilwon pilwon commented Aug 13, 2015

@coffeemug It's great that you see this as a tremendous growth opportunity as well! 👍

For user's perspective, Option 2 is no doubt the most compelling option, however I feel Option 1 is (almost) as good as Option 2. You just need to show React developers how easy and fun it is to play with r.graphql in the data explorer. Building a backend is not a major burden if you also provide a rdb wrapper for express-graphql (officially supported by FB).

In my opinion, officially shipping an adapter (Option 3 or Option 4) may not bring the result you'd expect. There will most likely be tons of other open source projects doing that for a wide variety of databases so it probably won't be easy to stand out even with a first-mover advantage. It might be better to just leave it up to the community.

@pilwon

This comment has been minimized.

Copy link
Author

@pilwon pilwon commented Aug 13, 2015

The Relay team is already working on the spec to add real-time update functionality.

On their blog post:

Real-time updates. In collaboration with the GraphQL community, we're working to define a specification for subscriptions and provide support for them in Relay.

This clearly seems like an opportunity for RethinkDB as there aren't many databases out there that can even dream of supporting it natively... :feelsgood:

@rattrayalex

This comment has been minimized.

Copy link

@rattrayalex rattrayalex commented Aug 13, 2015

Sounds good to me @coffeemug and +1 to @pilwon 's comments. Have a great time rafting!! You guys deserve it!

@contra

This comment has been minimized.

Copy link

@contra contra commented Aug 13, 2015

Option 1 or Option 3 are best IMO 🌴

@andrerpena

This comment has been minimized.

Copy link

@andrerpena andrerpena commented Aug 14, 2015

@coffeemug and others, I'd like to say that the attitude I'm seeing here in this thread is one of the reasons why I'm building my product on top of RethinkDB even though it's not a market leader and even though it does not have support for Windows yet. You guys really care for innovation and promptly adopting new technologies that look promising, for the sake of progress. This is what technology is all about. Thanks everyone for your energy. RethinkDB rocks because of you.

@geddski

This comment has been minimized.

Copy link

@geddski geddski commented Aug 14, 2015

I like the no backend options even though they would be harder to implement. Fits with the Relay mentality of focusing on building your app, not writing services.

I think any effort here is awesome. Just one more reason to love the RethinkDB team. Just don't get acquired by FB ;)

@rattrayalex

This comment has been minimized.

Copy link

@rattrayalex rattrayalex commented Aug 17, 2015

Possibly relevant, the RisingStack claims to be working on this with their Graffiti project ( https://github.com/RisingStack/graffiti ) with an adapter in the works for the Thinky rethinkdb orm.

@ide

This comment has been minimized.

Copy link

@ide ide commented Aug 18, 2015

I'd like to echo the sentiment that RethinkDB could be a really good fit for Relay in particular because of your support for realtime queries.

@coffeemug - my inclination is that Option 3 (library) leading towards Option 1 (engine support) is a good path forward. There are many GraphQL queries that don't map to ReQL in an obvious way (ex: "get me this person's posts... that I'm allowed to see" -- the privacy constraint is implicit and GraphQL has the notion of the current user but ReQL doesn't), which is why I believe it's so important to have a library that lets us implement parts of a GraphQL query with our own code that calls into RethinkDB. Native support for GraphQL is a nice optimization underneath that. I would strongly advise against Option 2 because of the security issue you brought up... you really want complex security and privacy logic to live in the application layer.

@coffeemug

This comment has been minimized.

Copy link
Contributor

@coffeemug coffeemug commented Aug 18, 2015

@ide -- cool, thanks for the feedback. Do you have an example of how to do security with GraphQL you could point me to? I couldn't find anything online (other than a vague "do it yourself").

Wouldn't the developer have to analyze every GraphQL query themselves to do security? That sounds like a huge burden, and it feels strange that security provisions aren't in the spec. I feel like I'm missing something, but I can't seem to find any information on this.

@troybetz

This comment has been minimized.

Copy link

@troybetz troybetz commented Aug 18, 2015

This might be helpful, it's from an interview with some of the relay team members

CHUCK: ...as far as security goes, I don’t want just anybody formulating GraphQL queries to send to my system. Is the structure inherently more secure? Or do you just secure your endpoint the same way you it with anything else? So, OAuth, authentication headers, HTTPS.

NICK: Yeah, we just use existing authentication.

NICK: Basically we effectively grab an access token from out external platform and we ensure that’s from a Facebook app. And then we piece out and then we just execute the string. So, GraphQL’s an explicitly higher level protocol than HTTP. It is an application layer protocol. That’s one of the things I find actually strange about REST, is the coupling of HTTP and the application level protocol. So, the authentication mechanism is completely orthogonal to GraphQL.

@danielmewes

This comment has been minimized.

Copy link
Member

@danielmewes danielmewes commented Aug 18, 2015

Thanks @compedit.
So that covers authentication, though it doesn't really cover authorization, i.e. assigning which users have access to which parts of the data. It seems to me that there's no standard for this yet as far as GraphQL is concerned?

@thelinuxlich

This comment has been minimized.

Copy link

@thelinuxlich thelinuxlich commented Mar 2, 2016

@coffeemug Is this project compatible with any databinding framework? I hope to use it with Vue.js

@coffeemug

This comment has been minimized.

Copy link
Contributor

@coffeemug coffeemug commented Mar 2, 2016

Horizon is agnostic to databinding frameworks -- you should be able to use a framework of choice fairly easily.

@mglukhovsky

This comment has been minimized.

Copy link
Member

@mglukhovsky mglukhovsky commented Mar 2, 2016

For those of you looking to get a Horizon invite, go here: https://horizon.io

@ktersius

This comment has been minimized.

Copy link

@ktersius ktersius commented Mar 7, 2016

@mglukhovsky I'm working on a pet project of mine and I'd really be interested to see what you guys have planned with Horizon. It might affect some of my design decisions... Can I also get an invite please?

@mglukhovsky

This comment has been minimized.

Copy link
Member

@mglukhovsky mglukhovsky commented Mar 8, 2016

@ktersius: you can sign up at https://horizon.io

@threepointone

This comment has been minimized.

Copy link

@threepointone threepointone commented Mar 8, 2016

Would you please add me too? Thank you!

@cymen

This comment has been minimized.

Copy link

@cymen cymen commented Mar 8, 2016

I'd love an invite too. Thanks!

@chentsulin

This comment has been minimized.

Copy link

@chentsulin chentsulin commented Mar 8, 2016

May I also get an inivite? Thanks!

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Mar 8, 2016

And me, thanks!

@threepointone

This comment has been minimized.

Copy link

@threepointone threepointone commented Mar 8, 2016

I apologize, shouldn't have asked here. Followed up on slack.

@byw

This comment has been minimized.

Copy link

@byw byw commented Mar 11, 2016

Could you add me as well? Thanks!

@TofPlay

This comment has been minimized.

Copy link

@TofPlay TofPlay commented Mar 11, 2016

Me too. Thanks 😊

@brownish

This comment has been minimized.

Copy link

@brownish brownish commented Mar 14, 2016

I would love an invite as well. Sounds great!

@believer

This comment has been minimized.

Copy link

@believer believer commented Mar 16, 2016

I would love an invite! Really excited about this! 😄

@rnenjoy

This comment has been minimized.

Copy link

@rnenjoy rnenjoy commented Mar 16, 2016

Me too :)

@knownasilya

This comment has been minimized.

Copy link
Contributor

@knownasilya knownasilya commented Mar 17, 2016

@coffeemug if you can spare an invite 👍

@mquandalle

This comment has been minimized.

Copy link

@mquandalle mquandalle commented Mar 17, 2016

I have subscribed to this thread because I’d like to follow RethinkDB+GraphQL developments, but I’m getting a bit bored to be notified everytime someone requests an invite. Could you consider another process for invite requests (like a google form, or writing your name on a etherpad document, or something else)?

@knownasilya

This comment has been minimized.

Copy link
Contributor

@knownasilya knownasilya commented Mar 17, 2016

Or whoever upvotes your comment?

@stream7

This comment has been minimized.

Copy link

@stream7 stream7 commented Mar 17, 2016

Or people could join the slack team first http://slack.rethinkdb.com/ and ask for an invite there?

@coffeemug

This comment has been minimized.

Copy link
Contributor

@coffeemug coffeemug commented Mar 17, 2016

I'm thinking through another process with @mglukhovsky right now. We tried Slack and a web form, but it's getting lost in the comments. We should figure out how to handle this better in a day or two. Sorry everyone for getting spammed with invite requests!

@davidbilly

This comment has been minimized.

Copy link

@davidbilly davidbilly commented Mar 26, 2016

@coffeemug Hi, could you invite me into Horizon project. I been asked on slark group, but nobody reply me :( Thanks!

@mglukhovsky

This comment has been minimized.

Copy link
Member

@mglukhovsky mglukhovsky commented Apr 8, 2016

Hey guys, we had an unexpected level of interest in this project. We're starting to open the developer preview for Horizon (though it's still early.)

You can sign up for Horizon here: https://horizon.io

Join us in #horizon on Slack if you have questions.

I'd like to keep the volume of traffic on this conversation minimal for existing participants, so I'm going to lock this conversation for the next few weeks to collaborators. I'll unlock it as Horizon nears general availability.

We'll post updates as they come -- thanks for your patience!

@rethinkdb rethinkdb locked and limited conversation to collaborators Apr 8, 2016
@danielmewes danielmewes modified the milestones: subsequent, backlog Apr 29, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
You can’t perform that action at this time.