Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Fields filtering with include

Open
#1,475 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rails, ruby
Domain
api, backend

Research direction

Start in lib/jsonapi/resource_serializer.rb at JSONAPI::ResourceSerializer#supplying_relationship_fields and reproduce the fields[events]=name plus include=establishment case described in the issue. Verify the response hash retains the relationships key while still applying field filtering; the intended behavior should be confirmed before changing the set intersection.

Written by the indexing model from the issue text.

Description

Version 0.9.12

When using fields[events]=name + include=establishment the key relationships disappear from the response hash.

Basic association is events belongs_to establishment

Issue is coming from here:


# JSONAPI::ResourceSerializer#supplying_relationship_fields

def supplying_relationship_fields(resource_klass)
        @_supplying_relationship_fields.fetch resource_klass do
          relationships = Set.new(resource_klass._relationships.keys.map(&:to_sym))
          cur = resource_klass
          while cur != JSONAPI::Resource
            if @fields.has_key?(cur._type)
              # here... 
              # It always empty the Set
              #relationships &= @fields[cur._type]
              break
            end
            cur = cur.superclass
          end
          @_supplying_relationship_fields[resource_klass] = relationships
        end
      end

Commenting relationships &= @fields[cur._type] solves this issue. @DavidMikeSimon could you describe your mind here? I know it was a loooong time ago but your help might help to correctly fix this issue.

Dominant language
Ruby
Stars
2.3k
Forks
546
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JSONAPI-Resources/jsonapi-resources

All issues in JSONAPI-Resources/jsonapi-resources

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.