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

Attempting to declare a connection field on an interface results in an error #40

Open
dpehrson opened this issue Dec 9, 2016 · 4 comments
Labels

Comments

@dpehrson
Copy link
Contributor

dpehrson commented Dec 9, 2016

Use case

Multiple node objects in my schema can be commented on, they should share a comments field which is relay connection of comment nodes and a declared interface to allow for polymorphic querying.

Expected results

I should be able to declare an interface with a field that is a relay connection for querying as such:

interface :commentable do
  connection field :comments, node_type: :comment
end

Actual results

Errors 😭

== Compilation error on file web/graph/schema.ex ==
** (FunctionClauseError) no function clause matching in Access.fetch/2
    (elixir) lib/access.ex:147: Access.fetch({:field, [line: 41], [:comments, [node_type: :comment]]}, :node_type)
    (elixir) lib/access.ex:179: Access.get/3
    (absinthe_relay) lib/absinthe/relay/connection/notation.ex:41: Absinthe.Relay.Connection.Notation.naming_from_attrs!/1
    (absinthe_relay) expanding macro: Absinthe.Relay.Connection.Notation.connection/1
    web/graph/schema.ex:41: App.Graph.Schema (module)
    (absinthe) expanding macro: Absinthe.Schema.Notation.interface/2
    web/graph/schema.ex:40: App.Graph.Schema (module)
    (elixir) lib/kernel/parallel_compiler.ex:117: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1
@bruce bruce added the Type:Bug label May 24, 2017
@AlexanderEkdahl
Copy link

Any updates on this? I'm seeing a different error.

@dpehrson
Copy link
Contributor Author

I originally reported this so long ago that I imagine a lot has changed about the library since then.

This only came up for me during a proof-of-concept testing phase and I never ended up actually having to use it so I never bothered trying to fix it like with other issues.

@benwilson512 and @bruce are super responsive to issues if you can help narrow down the error case. Check out #83 for an example of what I've done in the past.

@benwilson512
Copy link
Contributor

This is somewhere between a bug fix and a feature request. We mostly just need to make the connection macro know about interfaces.

@AlexanderEkdahl
Copy link

I may take a stab at this. Until then you can do:

interface :commentable do
  field :comments, :comment_connection
end

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

No branches or pull requests

4 participants