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

Broadcasting for nodes field #5006

Closed
pert5432 opened this issue Jul 2, 2024 · 1 comment · Fixed by #5012
Closed

Broadcasting for nodes field #5006

pert5432 opened this issue Jul 2, 2024 · 1 comment · Fixed by #5012

Comments

@pert5432
Copy link

pert5432 commented Jul 2, 2024

Hi,
We are trying to implement broadcasting and can't set broadcastable: true for nodes fields from Relay.

Setting it in the field definition like this: field :replies, Types::Chat::MessageType.connection_type, broadcastable: true
doesn't work presumably because connection_type doesn't pass any field options to creation of the node field:
(schema/member/relay_shortcuts.rb:53)

def connection_type
   initialize_relay_metadata
   @connection_type ||= begin
     conn_name = self.graphql_name + "Connection"
     edge_type_class = self.edge_type
     Class.new(connection_type_class) do
       graphql_name(conn_name)
       edge_type(edge_type_class) # This function takes field_options param
    end
  end
end

types/relay/connection_behaviors.rb:57

def edge_type(edge_type_class, ..., field_options: nil)
...

...
  define_nodes_field(node_nullable, field_options: field_options) # field_options is always nil here because connection_type does not set it when calling edge_type
end

If I hardcode the parameter into the edge_type call like this it makes the field broadcastable:

def connection_type
...
edge_type(edge_type_class, field_options: { broadcastable: true }) 
...
end

I tried setting the param in our connection type like so nodes_field(field_options: { broadcastable: true }) with no success.
The connection type is used in our BaseObject like this: connection_type_class Types::ExtendedConnection.

Is there a way we can set these fields to broadcastable?

@rmosolgo
Copy link
Owner

rmosolgo commented Jul 2, 2024

Hey, thanks for the detailed report. I agree there should be some way to make nodes broadcastable. It seemse like field_options is supposed to be used for that, but I guess it's not quite doing the job! I'll take a look soon and follow up here.

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 a pull request may close this issue.

2 participants