Skip to content

Allow callable() as field deferring mechanism #739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 6, 2025

Conversation

oprypkhantc
Copy link
Contributor

@oprypkhantc oprypkhantc commented Mar 15, 2025

Closes #738

@codecov-commenter
Copy link

codecov-commenter commented Mar 15, 2025

Codecov Report

Attention: Patch coverage is 93.10345% with 2 lines in your changes missing coverage. Please review.

Project coverage is 94.86%. Comparing base (53f9d49) to head (7751070).
Report is 115 commits behind head on master.

Files with missing lines Patch % Lines
src/Mappers/CannotMapTypeException.php 75.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #739      +/-   ##
============================================
- Coverage     95.72%   94.86%   -0.87%     
- Complexity     1773     1838      +65     
============================================
  Files           154      175      +21     
  Lines          4586     5000     +414     
============================================
+ Hits           4390     4743     +353     
- Misses          196      257      +61     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@oojacoboo oojacoboo merged commit d64cb99 into thecodingmachine:master Jun 6, 2025
11 checks passed
@oojacoboo
Copy link
Collaborator

@oprypkhantc so I've merged this, but am getting an error locally.

current() expects exactly 1 argument, 0 given
vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php:63

Any ideas on this?

@oojacoboo
Copy link
Collaborator

@oprypkhantc ^^

@oprypkhantc
Copy link
Contributor Author

Sorry, I somehow missed all GitHub notifications from that time it seems 🤔

It's hard to tell from that trace, as there's no ->current() call on that line. I did also update to dev-master and am not getting any errors 👀

@andrew-demb
Copy link
Contributor

current() expects exactly 1 argument, 0 given
vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php:63

Yeah, it seems that for some reason graphqlite created \GraphQL\Deferred with \current(...) as a callable argument.

@oojacoboo can you share the graphql query and types definition which fail with the current master?

@oojacoboo
Copy link
Collaborator

@oprypkhantc @andrew-demb

book(id: "%s") {
    id
    authors {
        addresses {
            type {
                key
            }
        }
    }
}

This call in the stack looks particularly interesting:

{
      "file": "vendor/webonyx/graphql-php/src/Server/Helper.php",
      "line": 204,
      "function": "wait",
      "class": "GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter",
      "type": "->",
      "args": [
        {
          "adoptedPromise": {
            "state": "fulfilled",
            "result": {
              "errors": [
                {
                  "message": "Internal server error",
                  "locations": [{ "line": 8, "column": 33 }],
                  "path": ["book", "authors", 0, "addresses", 0, "type", "key"]
                }
              ]
            }
          }
        }
      ]
},

So, on line 63 of \GraphQL\Executor\Promise\Adapter\SyncPromise, it's trying to resolve the promise current(). When debugging the exception there. That's the value of $executor.

@andrew-demb
Copy link
Contributor

@oojacoboo can you share code of the "address type" graphql type?

Is it return any callable in some field?

@oojacoboo
Copy link
Collaborator

oojacoboo commented Jun 12, 2025

@andrew-demb sure - quite simple class. No callables.

#[GraphQLite\Type]
#[GraphQLite\Input]

class AddressType
{

    public const string BILLING = 'billing';
    public const string CURRENT = 'current';
    public const string LEGAL = 'legal';
    public const string MAILING = 'mailing';
    public const string PHYSICAL = 'physical';


    #[GraphQLite\Field(for: 'AddressTypeInput')]
    protected string $key;


    public function __construct(string $key)
    {
        $this->key = $key;
    }


    public function __toString(): string
    {
        return $this->getKey();
    }


    #[GraphQLite\Field(outputType: 'ID!')]
    public function getKey(): string
    {
        return $this->key;
    }
}

@andrew-demb
Copy link
Contributor

@oojacoboo I'm out of ideas.

Let's revert then until we find the reason to not lock releases.

@oprypkhantc
Copy link
Contributor Author

@oojacoboo Could it be that you updated other dependencies alongside thecodingmachine/graphqlite which caused the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cleaner and simpler field deferring
4 participants