overblog / dataloader-bundle Goto Github PK
View Code? Open in Web Editor NEWThis bundle allows to easy use DataLoaderPHP in your Symfony project through configuration.
License: MIT License
This bundle allows to easy use DataLoaderPHP in your Symfony project through configuration.
License: MIT License
Hi,
Could you please elaborate why the CacheMap is shared between all DataLoaders by default? This gave me all kinds of weird results whereby the promises of different entities were shared. For example, the following query would work if I either included the productType or location field, but not with both.
query {
products {
id
productType {
id
description
}
location {
id
name
}
}
}
I traced the error by inserting a few lines at https://github.com/overblog/dataloader-php/blob/master/src/DataLoader.php#L66 echo'ing $cacheKey and the $batchLoadFn (as a string) which showed me that the promise of productType would be returned for a location with the same id.
Manually overwriting the service definition as
services:
overblog_dataloader.cache_map:
public: false
shared: false
class: Overblog\DataLoader\CacheMap
solved all my problems and gave me the expected results. Is this a bug or am I doing something wrong?
Using a setup like this overblog/GraphQLBundle#73 (comment)
I get "Found no active DataLoader instance." when running any introspection query.
Sorry that I can't provide you more detail. Does this ring any bells though?
I've managed to hit DataLoader destroyed before promise complete.
in this file.
Since I'm using the bundle it's not explicitly clear how I got to a broken state.
It's likewise hard to create a minimal test case.
Any clues why this might happen?
Service ids with \ are not considered viable services. Since symfony 3.4+ recommends and auto configuring services as their FQCN, you need to introduce an alias to configure batch_load_fn.
To fix this, the Overblog\DataLoaderBundle\DependencyInjection\Configuration::SERVICE_CALLABLE_NOTATION_REGEX
should be changed. We could use the same capture group definition as for function in PHP_CALLABLE_NOTATION_REGEX
, i guess.
Hi,
I'm a bit in the dark on how to implement this in my schema. I'm using the GraphQLBundle. In my schema, I have a query field named "contracts" which returns an array of contract entities. Each contract contains a one-to-many to an entity named "location". How would I implement this?
In my ContractsResolver class, I'd like to return a promise from my ContractLoader which returns an array of contracts. Then, the locations field on each contract should also return a promise resolving to an array of locations. How should I implement this in my resolvers and scheme?
We have restriction to Symony 3 | 4 in composer.json. What's necessary to allow Symfony 5.0 support?
Hi, how can I pass the ResolveInfo $info to the dataloader batch function to query only the required fields?
services:
app.graph.ship_repository:
class: AppBundle\Entity\Repository\ShipRepository
factory: ["@doctrine.orm.entity_manager", getRepository]
arguments:
- AppBundle\Entity\Ship
app.graph.ships_loader:
class: AppBundle\GraphQL\Loader\ShipLoader
arguments:
- "@overblog_graphql.promise_adapter"
- "@app.graph.ship_repository"
#graphql
overblog_graphql:
definitions:
schema:
query: Query
services:
promise_adapter: "webonyx_graphql.sync_promise_adapter"
#dataloader
overblog_dataloader:
defaults:
promise_adapter: "overblog_dataloader.webonyx_graphql_sync_promise_adapter"
loaders:
ships:
alias: "ships_loader"
batch_load_fn: "@app.graph.ships_loader:all"
Again, what is the purpose of the adapter? I create service, to create a service which lets the adapter call a load_fn, but it seems from the following example, that I still have to somehow collect the IDs:
public function resolveShip($shipsID)
{
$promise = $this->container->get('ships_loader')->load($shipsID);
return $promise;
}
So I could simply spare a lot of config and simply use the deffered from webonyx and collect my ids anyway. I could create a single service (instead of two) with almost zero config (using autoconfig/autowire) which does exactly this. Also the resolver usage does magically get shipIds, while actually the resolver would not get IDs, but the value/data being resolved.
The resolver usage combined with previous explanation feels like an "1. do this 2. ??? 3. profit?" currently ;(.
Hi there, I'm trying to get up to speed on GraphQL and I think either the example in the README is wrong, or else maybe could just use some clarification for n00bs such as myself.
Specifically, the "Usage in a resolver" seems to be calling the "load" function of ShipLoader, but of course ShipLoader does not have a "load" function, only an "all" function.
Is there supposed to be an intermediate object, or some functions added via inheritance?
Hello,
I'm wondering if it's possible to use a redis adapter (like SNC) for caching?
Hello,
I'm using your excellent GraphQL bundle and so the dataloader.
In one of my type, I need to load another type using the dataloader. To do that, I use a property of my first type, but this property can be null sometimes. Of course, the result for this key would be null and this is what I'm looking for. But now, this throws an error because of the checkKey method of overblog/dataloader-php/src/DataLoader.php
Thank you a lot
Jourdan
Currently, it seems only possible to create data loaders dynamically with the bundle's configuration.
But that registers dynamic services that you need to inject in your resolvers.
If you use autowire, that becomes a pain.
What if you can just create a dataloader with PHP, and that this bundle automatically finds it and registers it?
Hi, thank you for the really nice library.
I wanted to ask whether you planning to release a new version with the fixes in main branch. It would be awesome as it fixes compatibility with PHP 8.1.
If anything has to be done before, I'm happy to help.
The batch load functions and classes look pretty much always the same so I'd like to get rid of them in favor of some global batch function that would receive the name of the data loader and the ids and would return a promise just like normal batch_load_fn. Currently I hacked it using __call
but it's not ideal.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.