rmosolgo / rmosolgo/graphql-ruby

@export directive

Open
#5,329 4 comments 0 reactions 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

I was reading through the documentation and I found a few mentions of the @export directive.

I can see how you can easily create a custom directive. My plan of action would be to add the variable when the directive is resolved, but I don't know where to hook it up so you don't hit the Variable $xxx is used by anonymous query but not declared error. (I also don't know if the query is done top to bottom, so if I would add the @export directive on top and then use it later, if that would work.

Having very little experience with the source code of this gem, I was wondering if you deem it feasible to implement an @export directive with the current hooks. Any pointers in a specific direction would also be super helpful 😄.

(running the resolve and changing the variable is also not very clean at the moment in my proof of concept)
I'm doing

context.query.variables.instance_eval("@storage")[arguments[:as]]

Which obviously goes deep in the internals of the implementation. But I don't know if there's a cleaner way for this?

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 by tracing custom directive resolution, variable validation around the “Variable $xxx is used by anonymous query but not declared” error, and the behavior of context.query.variables. Determine whether directive order supports exporting a value for later use and identify a public hook that avoids direct access to @storage; done means @export works without that internal workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, ruby
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.