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

Visibility Profiles and interface implementations #5233

Closed
fhoeben opened this issue Feb 12, 2025 · 1 comment · Fixed by #5236
Closed

Visibility Profiles and interface implementations #5233

fhoeben opened this issue Feb 12, 2025 · 1 comment · Fixed by #5236

Comments

@fhoeben
Copy link

fhoeben commented Feb 12, 2025

Describe the bug

When we enable GraphQL::Schema::Visibility our types can no longer be used in fragments on interfaces implemented by the parent classes. But in the schema they are still listed as implementing the interface.

We get the following error when trying to use the fragments, which work if we don't enable visibility: Fragment on Person can't be spread inside Node

Versions

graphql version: 2.4.9
rails (or other framework): 7.1
other applicable versions (graphql-batch, etc): none

GraphQL schema

Include relevant types and fields (in Ruby is best, in GraphQL IDL is ok). Any custom extensions, etc?

class NodeType < GraphQL::Schema::Object
  implements(GraphQL::Types::Relay::Node)

  field :id, ID, null: false
end

class Person < Types::Base::NodeType
  field :name, String
end

class Types::QueryType < GraphQL::Schema::Object
        field(:node, GraphQL::Types::Relay::Node, null: true) do
          argument :id, ID, required: true

          def resolve(_, args, ctx)
...
          end
        end
end

class ApplicationSchema < GraphQL::Schema
  
      query(Types::QueryType)
      use(GraphQL::Schema::Visibility)
end

GraphQL query

Example GraphQL query and response (if query execution is involved)

        query {
          node(id: "abc") {
            id
            ... on Person { name }
          }
        }

Error with message Fragment on Person can't be spread inside Node

Expected behavior

Query result (either null if person with id abc cannot be found or id and name if one is found)

Actual behavior

We get an error

Additional context

When I add the following line to the Person class it works as expected:
implements(GraphQL::Types::Relay::Node)

But in my actual schema I have a lot of types that should all implement the Node interface and I don't want to repeat myself each time, that's why I created the superclass. This works if I don't add use(GraphQL::Schema::Visibility) to my schema.

What I see in the schema for Person (even with visibility enabled), so this seems OK:
type Person implements Node {

@rmosolgo
Copy link
Owner

Hey, thanks so much for the detailed report. I agree, it should still work the way it used to. I'll take a look and follow up here soon!

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