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

SubscribePayload support for query/id #188

Closed
artola opened this issue May 29, 2021 · 7 comments
Closed

SubscribePayload support for query/id #188

artola opened this issue May 29, 2021 · 7 comments
Labels
question Further information about the library is requested

Comments

@artola
Copy link

artola commented May 29, 2021

Source code

export interface SubscribePayload {

Expected Behaviour
SubscribePayload should support query (text) or id (hashed query) for persisted queries (might be an union type).

Actual Behaviour
Only query is allowed and it is required.

@enisdenjo
Copy link
Owner

Hey there! Simply use the query field to transmit the hash ID. Please check the "ws server and client usage with persisted queries" recipe.

@enisdenjo enisdenjo added the question Further information about the library is requested label May 29, 2021
@artola
Copy link
Author

artola commented May 29, 2021

@enisdenjo Thanks and sorry, I did not see the recipe.

@artola artola closed this as completed May 29, 2021
@enisdenjo
Copy link
Owner

Hey @artola, quick heads up: [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.

@artola
Copy link
Author

artola commented Jun 1, 2021

@enisdenjo Thanks for the info. But still I have my doubts about the query property as you know still it is required.

readonly query: string;

At least should be optional or null if it is not intended to be used.

FYI @michaelstaib

@michaelstaib
Copy link

@enisdenjo @artola lets do a PR to the actual HTTP spec to first get this change into the HTTP spec. I spoke to @IvanGoncharov about persisted queries a while ago and the general idea was to move the top-level id into extensions. But we never actually discussed that query can become optional in the you pass along id. In general that would mean query can be null when extension is set. The validation is then up to the server.

This for instance this how an apollo persisted query request looks like.

{
  "extensions": {
    "persistedQuery": {
      "version": 1,
      "sha256Hash": "ecf4edb46db40b5132295c0291d62fb65d6759a9eedfa4d5d612dd5ec54a6b38"
    }
  }
}

So let me do a PR to the HTTP spec and then discuss things on that repo.

@michaelstaib
Copy link

I will write something to the following issue:
graphql/graphql-over-http#38

@enisdenjo
Copy link
Owner

I try mirroring the HTTP spec as much as possible.

Having said that, if we make the query field optional there, no reason to keep it required in the WS spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information about the library is requested
Projects
None yet
Development

No branches or pull requests

3 participants