rmosolgo / rmosolgo/graphql-ruby

Better detection for when items were scoped?

Open
#4,848 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
5.4k
Forks
1.4k
Avg merge
23h 19m
Merged PRs (30d)
28

Description

Currently, this library checks for whether or not items were scoped by using object equality:

https://github.com/rmosolgo/graphql-ruby/blob/b0d289ebd3ce0f8131d5c04708ece69585d1fad8/lib/graphql/schema/field/scope_extension.rb#L14-L18

This works when scope_items really did something, but not if you want to skip authorization altogether. For example, if you've got a list of items from an external service, and you want to return them as-is, without scoping or authorization, you'd have to do this:

def self.scope_items(items, ctx)
  items.dup # Make a shallow copy so GraphQL-Ruby will know that we authorized this list
end 

I bet there's a more robust way to implement this check (and maybe to implement the runtime metadata, too). I'm going to consider it for 3.0.

Contributor guide

Open the contributing guide

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.

Research direction

Start with lib/graphql/schema/field/scope_extension.rb at the linked lines 14-18, then examine how runtime metadata is handled. Define a more robust way to distinguish authorized, unchanged external-service lists from lists that were actually scoped; the work is done when this no longer requires a shallow copy and the behavior is covered by the relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, ruby
Domain
api, authorization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.