This repository was archived by the owner on Dec 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 150
Data loading workflow [DRAFT]
Valerii Naida edited this page Apr 8, 2019
·
24 revisions
- Resolver: [FieldConfigInterface, QueryContextInterface, QueryInterface, QueryInterface]
- Search Criteria creating [query, query parametrs, query context] => SearchCriteria
- Data searhing [SearchCriteria] => matched identifiers
- Data loading[query info, matched identifiers] => loaded data
interface ResolverInterface
{
public function resolve(
FieldConfigInterface $fieldConfig,
QueryContextInterface $queryContext,
QueryInterface $query,
array $parentResolvedValue = []
);
}Ideally, initialize and pass just what resolver needed
interface FieldConfigInterface
extends \Magento\Framework\GraphQl\Config\ConfigElementInterfaceinterface QueryContextInterface
{
public function getStore(): StoreInterface;
public function getUser(): UserInterface;
}Open question:
- Immutability with setExtensionAttribues (for example for collect warnings)
- Returning whole object or just identificator (store_code, user_id)
interface QueryInterface
{
public function getStructure(): ResolveInfo;
public function getArguments(): array;
public function getVariables(): array;
}Could be used as data container between resolvers
SearchCriteriaFactoryInreface || SearchCriteriaBuilderInreface - responsible for Search Criteria creating
interface SearchCriteriaFactoryInreface
{
public function create(
QueryInterface $query,
[QueryContextInterface $queryContext]
): SearchCriteriaInterface;
}Could has state for resolving N+1 problem (descibed bellow).
interface DataSearchInterface
{
public function search(
SearchCriteriaInterface $searchCriteria
): array;
}Open question:
- A format of output data
- Work with current search API or using a lighter version
- Covering indexes (when the index contains enough data and don't need to load data from raw source)
interface DataProviderInterface
{
public function load(
QueryStructure $queryStructure,
QueryContextInterface $queryContext,
array $identifiers,
array $parentResolvedValue = []
): DataInterface;
}
QueryOutputProcessingInterface - responsible for processing data before output (for example set warnings to result)
interface QueryOutputProcessingInterface
{
public function process(DataInterface $data): void;
}Base implementation works with \GraphQL\Executor\ExecutionResult (webonyx)
// Child resolver
$this->searchCriteriaBuilder->addFilter(...);
return $this->valueFactory->create(function () use ($query, $queryContext) {
$searchCriteria = $this->searchCriteriaBuilder->create();
$searchResult = $dataSearch->search($searchCriteria);
$data = $this->dataProvider->load($query, $queryContext, $searchResult);
return $data;
});- Resolver could be mutual for all queries: register 'DataSearchInterface' and
DataProviderInterfaceper GraphQL type
- Roadmap
- ZenHub task board (requires GitHub sign-in)
- Weekly calls:
- Thursday, 15:00 UTC
- Video conference link - https://bluejeans.com/180764326
- Recordings - https://goo.gl/5Q7QAw
- Slack: #graphql (Use http://tinyurl.com/engcom-slack to register)