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

add support for config functions (on subscriptions) in hydrate/2 #1273

Open
bsanyi opened this issue Aug 17, 2023 · 0 comments
Open

add support for config functions (on subscriptions) in hydrate/2 #1273

bsanyi opened this issue Aug 17, 2023 · 0 comments

Comments

@bsanyi
Copy link

bsanyi commented Aug 17, 2023

Environment

  • Elixir version (elixir -v): 1.14.5
  • Absinthe version (mix deps | grep absinthe): 1.7.4
  • Client Framework and version (Relay, Apollo, etc): Graphiql, Absinthe.run

Expected behavior

When using an SDL schema, please support adding a config function to a subscription.

    type RootSubscriptionType {
      subs(id: ID!): String
    }
    def hydrate(%Absinthe.Blueprint{}, _) do
      %{
        subscription: [%{subs: [config: &SomeModule.conf_my_subscription/2]}]
      }
    end
    defmodule SomeModule do
      def conf_my_subscription(%{id: id}, _) do
        {:ok, topic: "topic:#{id}"}
      end
    end

I expect that the subscription { subs(id: "hello") } runs the conf_my_subscription function at the time of
submitting the subscription request, and subscribes the client to the topic "topic:hello".

Actual behavior

Currently the hydration above is considered invalid. There's no way to add a config function to a subscription when using SDL schemas.

Relevant Schema/Middleware Code

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

No branches or pull requests

1 participant