Code Monkey home page Code Monkey logo

Comments (5)

enisdenjo avatar enisdenjo commented on May 17, 2024 1

Good idea! We should offer a handler like that.

However, onOperation is a better suited name for when an operation resolves, and onSubscribe for immediately when the user requests a subscription (operation execution).

The current onSubscribe has to change. Even if its a breaking change, its worthwhile! Check #40 out.

from graphql-ws.

enisdenjo avatar enisdenjo commented on May 17, 2024

Currently you'd have a hard time setting up persisted queries because AST parsing is run on the subscribe payload query before the onSubscribe.

https://github.com/enisdenjo/graphql-transport-ws/blob/e9d8ee45487f2a81c493b1b6d8d1c209111ff878/src/server.ts#L403-L436

I will lift this limitation and then you should be able to request something like this:

{
  "id": "unique-transport-id",
  "type": "subscribe",
  "payload": {
    "query": "persisted-query-id",
    "variables": { "hey": "there" }
  }
}

Find the persisted query in onSubscribe, supplement it, validate and then execute.

from graphql-ws.

n1ru4l avatar n1ru4l commented on May 17, 2024

Could we implement a handler that is run before that e.g. onOperation?

from graphql-ws.

enisdenjo avatar enisdenjo commented on May 17, 2024

🎉 This issue has been resolved in version 1.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from graphql-ws.

enisdenjo avatar enisdenjo commented on May 17, 2024

Quick heads up, @n1ru4l, [email protected] just landed, adding the extensions field in the subscribe message payload.

This means that you now can pass along the persistedQuery through that field on each subscribe as various other libraries/frameworks suggest. And of course, extend with your custom requirements. 😄

from graphql-ws.

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.