Code Monkey home page Code Monkey logo

Comments (20)

helfer avatar helfer commented on March 28, 2024 8

@gadicc We're rewriting the server right now, and one of the things we want to work on after the refactor is websocket connections, which should enable some of the things you propose.

from apollo-server.

stubailo avatar stubailo commented on March 28, 2024 5

Thanks for opening this issue! I think it would be very exciting to experiment with the proposed features from react Europe, and were in a unique position to do it since we are the only team who have both a client and server implementation.

I completely agree that putting a GraphQL endpoint in a database is not the right approach, since not all of your data will be in that one source. So once we figure out how data streaming from resolvers should work, we should see if that can be easily made to work with rethinkdb live queries (as well as meteor MongoDB live queries)

from apollo-server.

willmkt avatar willmkt commented on March 28, 2024 2

You may want to take a look at this project, but it does not usr apolloserver

https://github.com/bhoriuchi/vue-graphql-rethink

from apollo-server.

helfer avatar helfer commented on March 28, 2024 1

@ivosabev we're working on websocket integration in #272, which is the first step in this direction.

from apollo-server.

helfer avatar helfer commented on March 28, 2024 1

Closing this for now, but we can keep the discussion going.

from apollo-server.

gadicc avatar gadicc commented on March 28, 2024

I'd also like to relate this back to apollographql/apollo-client#257 (using apollo with rethinkdb horizon).

I'm still new to all of this, but can't we look at this another way? Instead of horizon implementing a graphQL server that can be used with the apollo client (and then, needing two distinct apolloClient instances), doesn't it make more sense to make this work with apollo server? And potentially having RethinkDB officially recommend Apollo?

I was thinking something like:

export const resolvers = {
  users(parent, args, context, liveQuery) {
    const query = r.table('users');
    rethinkChangeFeedAdaptor(conn, query, liveQuery);
  }
}

function rethinkChangeFeedAdaptor(conn, query, liveQuery) {
  // Tell the server not to use/expect an immediate return result
  // and specify the primary key.
  liveQuery.init('id');

  query.changes({ includeStates: true }).run(conn, (err, cursor) => {
    cursor.each(row => {
      if (['add','remove','change'].includes(row.type))
        liveQuery[row.type](row.new_val);
    });
  }
}

Just some musings :) What are the advantages of rethinkDB implementing their own GraphQL server?

from apollo-server.

gadicc avatar gadicc commented on March 28, 2024

Facebook have also been doing some work on this, see GraphQL Future at react-europe 2016 on Youtube. They have experiments for live queries, and mentioned that there are plans to make their server infrastructure reactive in the future.

(For now, however, they've done more work on event-based subscriptions (facebook/relay#541), powering FB comments & likes, and the live reactions on streaming videos, amongst others.)

The live query experiment (which hasn't seen production use yet) looks like this (from 17:19):

Query:

{
  feed {
    stories {
      author { name }
      message
      likeCount @live
    }
  }
}

Initial payload (like normal):

{
  "feed": {
    "stories": [
      {
        "author": { "name": "Lee Byron" },
        "message": "GraphQL est grand!",
        "likeCount": 5
      },
      {
        "author": { "name": "Dan Schafer" },
        "message": "Anyone for lunch?",
        "likeCount": 5
      },
      {
        "author": { "name": "Christopher Chedeau" },
        "message": "React Native est l'avenir",
        "likeCount": 50
      }
    ]
  }
}

Sample update delta:

{
  "path": [ "feed", "stories", 0, "likeCount" ],
  "data": 6
}

from apollo-server.

gadicc avatar gadicc commented on March 28, 2024

Thanks, guys! This sounds awesome and I'm really excited for it.

from apollo-server.

peteflanagan avatar peteflanagan commented on March 28, 2024

Until the server is rewritten, is there a recommended method for creating a connector to RethinkDB such as thinky, rethinkdbdash or horizon?

from apollo-server.

helfer avatar helfer commented on March 28, 2024

@peteflanagan Without support for pushing data to the client, the only way to get some level of reactivity is to do polling. @amandajliu is working on GraphQL subscriptions, but those will only get you part of the way there.

Until support for the proposed live queries is implemented in GraphQL, I think it will be difficult to get the full benefit of RethinkDB in GraphQL.

from apollo-server.

frankdugan3 avatar frankdugan3 commented on March 28, 2024

Now that we have graphql-subscriptions, subscriptions-transport-ws and https://github.com/davidyaha/graphql-redis-subscriptions... I'm wondering if it would be possible to come up with a similar integration for RethinkDB?

Not quite the same as live queries, but it could be a significant improvement while waiting for the live query spec to mature.

from apollo-server.

rnenjoy avatar rnenjoy commented on March 28, 2024

I'm not qualified enough for making this myself. But wouldn't it be possible to just use a rethinkdb changefeed query inside a resolvers function, and keep that function returning results to the clients when changes occur? There is no really need for a pub/sub system?

from apollo-server.

DxCx avatar DxCx commented on March 28, 2024

hi @gadicc
I'm also interested in full websocket transport, and already have a working PoC implementation for that.
however i don't have the bandwidth to work on that further at the moment.
let's discuss because i think that we can meet and sync up, i don't see any reason to work in parallel.

from apollo-server.

gadicc avatar gadicc commented on March 28, 2024

Hey, @DxCx. Since the subscription support was added I never actually had a chance to look into this again. Realistically and unfortunately, I don't think I'll be able to dedicate any time to this until March at the earliest. Maybe if you can put your PoC online somewhere it might serve as a good basis for discussion and maybe others will be able to continue the work.

from apollo-server.

thomasmodeneis avatar thomasmodeneis commented on March 28, 2024

Hi,
I'm very new to this topic, but it crossed my mind that whatever streaming/realtime/live query you may want to do will stumb upon rethinkdb/rethinkdb#3471 and rethinkdb/rethinkdb#4133
How are you guys working around this issues, if you are at all ?
Cheers.

from apollo-server.

paralin avatar paralin commented on March 28, 2024

I would say this shouldn't be tied to RethinkDB at all, we just need an interface to return a stream of entries, and for Apollo client to understand this.

Furthermore Apollo supports pluggable network interfaces. The approach I would use to implement this is to add another interface (like SubscriptionNetworkInterface) that supports this, and then worry about the actual transport later.

from apollo-server.

ivosabev avatar ivosabev commented on March 28, 2024

Its 2017 any status updates?

from apollo-server.

paralin avatar paralin commented on March 28, 2024

http://github.com/rgraphql

from apollo-server.

rnenjoy avatar rnenjoy commented on March 28, 2024

Sorry for the dumb question. But why do we need a websocket integration? Why cant the transport method that already exists as a standalone package be used?

from apollo-server.

helfer avatar helfer commented on March 28, 2024

@rnenjoy we will probably only have one transport in the end that supports subscriptions and queries, but we're doing the work here to figure out what that should look like without complicating the subscriptions transport implementation.

from apollo-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.