Skip to content

Add urql live query #124

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jmatsushita
Copy link
Contributor

Adding @live queries in the style of https://github.com/n1ru4l/graphql-live-query

{
  "dependencies": {
    "@n1ru4l/graphql-live-query": "^0.10.0",
    "@n1ru4l/graphql-live-query-patch-jsondiffpatch": "^0.8.0",
    "@n1ru4l/push-pull-async-iterable-iterator": "^3.2.0",
    "@repeaterjs/repeater": "^3.0.4",
    "@urql/core": "^3.1.1",
    "eventsource": "^2.0.2",
    "graphql": "^16.6.0",
    "graphql-ws": "^5.11.3",
    "isomorphic-unfetch": "^4.0.2"
  }
}
  • Testing end to end with a graphql-yoga server with live queries enabled.
  • Also refactored the default query_ client to be in the Affjax.Node module to avoid depending on urql across tests.

Example (from the end to end test):

main :: Effect Unit
main = do

  client :: Client UrqlLiveQueryClient Directives Query _ _ <-
    createLiveQueryClient
      { url: "http://localhost:4000/graphql"
      , headers: [ ]
      }

  let
    event = liveQuery client "" $ live {} { greetings }

  handle <-
    HS.subscribe event \e -> do
      log "Live Query update received"
      logShow e

  launchAff_ do
    delay $ Milliseconds (3.0 * 1000.0)
    liftEffect $ HS.unsubscribe handle

@jmatsushita
Copy link
Contributor Author

@roryc89 I realised I had this PR stowed away jmatsushita#1 as a follow up to the directives one

It'll need some work I think to merge, but wanted at least to make you aware of it, and let you take a look at it before putting more work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant