nuwave / nuwave/lighthouse

Apply schema manipulation on input field definitions

Open
#1,417 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
3.5k
Forks
468
Avg merge
3h 9m
Merged PRs (30d)
2

Description

What problem does this feature proposal attempt to solve?

Lighthouse applies a process we call schema manipulation for some directives, allowing them to transform the GraphQL AST: https://github.com/nuwave/lighthouse/blob/301930b356faa63da681d564cbef41c7d312f2aa/src/Schema/AST/ASTBuilder.php#L133-L137

The directives @whereConditions and @orderBy implement the ArgManipulator interface. This is only called when they are defined directly on the args of a field.

While there is a directive interface for definitions that are directly applied on types (e.g. input Foo @example), we currently have no mechanism for traversing down into the fields of input types and apply transformation there.

Which possible solutions should be considered?

An implementation for this would entail:

  • Adding a new interface InputFieldManipulator
  • Add a method to ASTBuilder that applies it to input fields
  • Implement the interface for the ArgManipulator directives where it makes sense

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 reading ASTBuilder.php around the existing schema-manipulation logic and the ArgManipulator contract. Trace how @whereConditions and @orderBy are handled when placed on field arguments, then determine how equivalent traversal should reach input fields. Done means the new InputFieldManipulator mechanism exists and applicable ArgManipulator directives use it where appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, php
Domain
api, backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.