Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Data loading workflow [DRAFT]

Valerii Naida edited this page Apr 8, 2019 · 24 revisions

\Magento\CatalogGraphQl\Model\Resolver\Products\Query\Filter::getProductFields

Workflow:

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

Partipicsiants:

Resolver:

  • ResolverInterface - entry point from an application
interface ResolverInterface
{
    public function resolve(
		FieldConfigInterface $fieldConfig, 
		QueryContextInterface $queryContext, 
		QueryInterface $query, 
		array parentResolvedValue = []
	);
}

Ideally, initialize and pass just what resolver needed

  • FieldConfigInterface - represents 'field' GraphQL config element
\Magento\Framework\GraphQl\Config\ConfigElementInterface
  • QueryContextInterface - represents context data
interface 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)

  • QueryInterface - represents query structure and parameters

interface QueryInterface
{
    public function getStructure(): ResolveInfo    
    public function getArguments(): array;	
	public function getVariables(): array;
}
  • array $parentResolvedValue - contains values resolved by parrent resolvers (container between resolvers)

  • SearchCriteriaFactoryInreface - responsible for Search Criteria creating

interface SearchCriteriaFactoryInreface
{
    public function create(QueryInterface $query, QueryContextInterface $queryContext): SearchCriteriaInterface;    
}
  • DataSearchInterface - responsible for matching and searching data
interface DataSearchInterface
{
    public function search(SearchCriteriaInterface $searchCriteria): array;    
}

Open question:

  • 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)

  • DataProviderInterface - responsible for loading data from raw storage

interface DataProviderInterface
{
    public function load(QueryStructure $queryStructure, QueryContextInterface $queryContext, array $identifiers): 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)

Clone this wiki locally