Comments (15)
Related to #320
from graphql-php.
@Jalle19 I took a look at this and you're right. The issue is that the promise is resolved immediately. I need to do some research. It might be that we need to introduce our own Deferred concept, like they have done in Webonyx implementation. I don't like the idea, but if it that's what it takes then we'll do that.
from graphql-php.
Any news on this?
from graphql-php.
@crisu83 do you have time to look into this?
from graphql-php.
or @hungneox
from graphql-php.
Confirm this issue. loadBuffered()
is called everytime.
from graphql-php.
Guys, this issue is critical for production use. Do you have any suggestions? If you do not have time, tell me which way to dig?
from graphql-php.
This is literally the only reason I haven't swapped to this over my Youshido Fork.
from graphql-php.
@acelot I have my hands full right now with work, but the easiest way to look at it is to debug the deferred resolver test cases. I think that the main issue is related to how we're handling promises when executing them. CC @hungneox
from graphql-php.
Is there any thought to use https://github.com/overblog/dataloader-php
to solve the problem like almost everyone in node does?
from graphql-php.
I'm trying to adapt this library for my reactphp-project. I was able to perform a deferred request using lordthorzonus/php-dataloader. But for this I had to change the graphql-php code to support async calls. Because the existing executor have a race condition problem Execution::execute()
:
if ($data instanceof PromiseInterface) {
$data->then(function ($resolvedData) use (&$data) {
$data = $resolvedData;
});
}
<...>
return new ExecutionResult($data, $context->getErrors());
In this section of the code, the $data
variable will always be null
and will throw an exception.
To add support for asynchronous calls, I suggest adding a new method promiseExecute
which implements new PromisedExecutionInterface
:
class Execution implements ExecutionInterface, PromisedExecutionInterface
{
<...>
public function promiseExecute(
Schema $schema,
DocumentNode $documentNode,
$rootValue = null,
$contextValue = null,
array $variableValues = [],
?string $operationName = null,
?callable $fieldResolver = null,
?ErrorHandlerInterface $errorHandler = null
): PromiseInterface {
<...>
if ($data instanceof PromiseInterface) {
return $data->then(function ($resolvedData) use ($context) {
return new ExecutionResult($resolvedData, $context->getErrors());
});
}
<...>
return resolve(new ExecutionResult($data, $context->getErrors()));
}
<...>
}
I can provide PR, but I need help with tests.
from graphql-php.
@acelot PRs are more than welcome, I'll help you out with the tests!
from graphql-php.
from graphql-php.
@acelot is this issue resolved?
from graphql-php.
Yes, completely.
from graphql-php.
Related Issues (20)
- Laravel integration package HOT 2
- How to resolve inner type field defined in graphql language HOT 5
- Improving Performances HOT 12
- Wrong type-hints for errors in ExecutionResult
- Split buildSchema() into buildDocument() and buildSchema() (or similar) HOT 1
- Don't validate the schema again when validating the query against it
- Add a CHANGELOG
- Reduce redundant container calls while executing
- Exceptions can sometimes be wrapped inside two ExecutionExceptions HOT 2
- Misuse of Middleware HOT 3
- [Question] How to get requested fields inside resolver function? HOT 2
- `extend` doesn't work HOT 2
- Skipping schema validation greatly speeds up the execution HOT 1
- Error Reporting HOT 2
- [Question]: Question about an request
- Call to a member function getName() on null HOT 2
- How would I return a list of objects with total records HOT 1
- error with php 8.1 HOT 1
- ⚠️ Advance notice: this project will be archived ⚠️
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-php.