nuwave / nuwave/lighthouse

Writing mutations with null values in relations

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

Nobody has claimed this yet.

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

Description

Describe the bug

If you tries to execute a mutation with a null value in a relation, the mutation fails. It could be regression over https://github.com/nuwave/lighthouse/pull/1021.

Expected behavior/Solution

The mutation should work without working with the relation

Steps to reproduce

This mutation variables will work:

{
  "book": { 
    "upsert": [
      {
       "title": "test",
        "chapter": {
         "upsert": [{ "something": "value"}]
       }
      }
     ]
  }
}

This mutation variables won't work:

{
  "book": { 
    "upsert": [
      {
       "title": "test",
        "chapter": null
      }
     ]
  }
}

This mutation variables will work:

{
  "book": { 
    "upsert": [
      {
       "title": "test",
      }
     ]
  }
}

Output/Logs

Click to expand

{"message":"Argument 1 passed to Nuwave\\Lighthouse\\Execution\\Arguments\\ArgPartitioner::nestedArgResolvers() must be an instance of Nuwave\\Lighthouse\\Execution\\Arguments\\ArgumentSet, null given, called in /opt/app/vendor/nuwave/lighthouse/src/Execution/Arguments/ResolveNested.php on line 33","context":{"exception":{"class":"TypeError","message":"Argument 1 passed to Nuwave\\Lighthouse\\Execution\\Arguments\\ArgPartitioner::nestedArgResolvers() must be an instance of Nuwave\\Lighthouse\\Execution\\Arguments\\ArgumentSet, null given, called in /opt/app/vendor/nuwave/lighthouse/src/Execution/Arguments/ResolveNested.php on line 33","code":0,"file":"/opt/app/vendor/nuwave/lighthouse/src/Execution/Arguments/ArgPartitioner.php:26"}},"level":400,"level_name":"ERROR","channel":"testing","datetime":"2020-06-17T12:29:48.107377+00:00","extra":{}}


Lighthouse Version

4.14.1

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

Reproduce the failing mutation with chapter: null, then start at src/Execution/Arguments/ResolveNested.php line 33 and src/Execution/Arguments/ArgPartitioner.php line 26, as named in the error. Trace how null nested arguments are partitioned, and verify that the mutation succeeds while leaving the relation untouched.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, laravel, php
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.