improving graphql defs
This commit is contained in:
parent
2175e7ae2d
commit
665a550748
|
@ -17,10 +17,10 @@ type Materiau {
|
||||||
attachments: [Filefield]
|
attachments: [Filefield]
|
||||||
distributor: [Company]
|
distributor: [Company]
|
||||||
manufacturer: [Company]
|
manufacturer: [Company]
|
||||||
# famille:
|
# famille: String
|
||||||
# index:
|
# index: Int
|
||||||
# reference:
|
reference: String
|
||||||
# samples:
|
samples: [Sample]
|
||||||
}
|
}
|
||||||
|
|
||||||
type Article {
|
type Article {
|
||||||
|
@ -40,6 +40,11 @@ type Article {
|
||||||
memo: String
|
memo: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Sample {
|
||||||
|
showroom: Showroom
|
||||||
|
location: String
|
||||||
|
}
|
||||||
|
|
||||||
type Filefield {
|
type Filefield {
|
||||||
file: File!
|
file: File!
|
||||||
description: String
|
description: String
|
||||||
|
@ -64,15 +69,16 @@ type Showroom {
|
||||||
uuid: String!
|
uuid: String!
|
||||||
name: String!
|
name: String!
|
||||||
images: [Image]
|
images: [Image]
|
||||||
# email: String
|
email: String
|
||||||
# address: Adress
|
address: Address
|
||||||
# phone: String
|
phone: String
|
||||||
}
|
}
|
||||||
|
|
||||||
type Company {
|
type Company {
|
||||||
id: Int!
|
id: Int!
|
||||||
uuid: String!
|
uuid: String!
|
||||||
name: String!
|
name: String!
|
||||||
|
description: String
|
||||||
attachments: [Filefield]
|
attachments: [Filefield]
|
||||||
memo: String
|
memo: String
|
||||||
note: Int
|
note: Int
|
||||||
|
@ -80,8 +86,8 @@ type Company {
|
||||||
departement: String
|
departement: String
|
||||||
email: String
|
email: String
|
||||||
address: Address
|
address: Address
|
||||||
# infos
|
phone: String
|
||||||
# phone
|
infos: String
|
||||||
}
|
}
|
||||||
|
|
||||||
type Tag {
|
type Tag {
|
||||||
|
|
|
@ -26,6 +26,8 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
||||||
|
|
||||||
$this->addMateriau($registry, $builder);
|
$this->addMateriau($registry, $builder);
|
||||||
|
|
||||||
|
$this->addSample($registry, $builder);
|
||||||
|
|
||||||
$this->addArticle($registry, $builder);
|
$this->addArticle($registry, $builder);
|
||||||
|
|
||||||
$this->addCompany($registry, $builder);
|
$this->addCompany($registry, $builder);
|
||||||
|
@ -175,14 +177,55 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
||||||
->map('field', $builder->fromValue('field_distributor'))
|
->map('field', $builder->fromValue('field_distributor'))
|
||||||
);
|
);
|
||||||
|
|
||||||
// field_famille
|
// $registry->addFieldResolver('Materiau', 'famille',
|
||||||
// field_index
|
// $builder->produce('property_path')
|
||||||
// field_reference
|
// ->map('type', $builder->fromValue('entity:node'))
|
||||||
// field_samples
|
// ->map('value', $builder->fromParent())
|
||||||
|
// ->map('path', $builder->fromValue('field_famille.value'))
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// $registry->addFieldResolver('Materiau', 'index',
|
||||||
|
// $builder->produce('property_path')
|
||||||
|
// ->map('type', $builder->fromValue('entity:node'))
|
||||||
|
// ->map('value', $builder->fromParent())
|
||||||
|
// ->map('path', $builder->fromValue('field_index.value'))
|
||||||
|
// );
|
||||||
|
|
||||||
|
$registry->addFieldResolver('Materiau', 'reference',
|
||||||
|
$builder->produce('property_path')
|
||||||
|
->map('type', $builder->fromValue('entity:node'))
|
||||||
|
->map('value', $builder->fromParent())
|
||||||
|
->map('path', $builder->fromValue('field_reference.value'))
|
||||||
|
);
|
||||||
|
|
||||||
|
$registry->addFieldResolver('Materiau', 'samples',
|
||||||
|
$builder->produce('property_path')
|
||||||
|
->map('type', $builder->fromValue('entity:node'))
|
||||||
|
->map('value', $builder->fromParent())
|
||||||
|
->map('path', $builder->fromValue('field_samples'))
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ___ _
|
||||||
|
// / __| __ _ _ __ _ __| |___
|
||||||
|
// \__ \/ _` | ' \| '_ \ / -_)
|
||||||
|
// |___/\__,_|_|_|_| .__/_\___|
|
||||||
|
// |_|
|
||||||
|
protected function addSample(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
|
||||||
|
$registry->addFieldResolver('Sample', 'showroom',
|
||||||
|
$builder->callback(function($parent, $args){
|
||||||
|
return \Drupal\taxonomy\Entity\Term::load($parent['target_id']);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
$registry->addFieldResolver('Sample', 'location',
|
||||||
|
$builder->callback(function($parent, $args){
|
||||||
|
return $parent['location'];
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// _ _ _ _
|
// _ _ _ _
|
||||||
// /_\ _ _| |_(_)__| |___
|
// /_\ _ _| |_(_)__| |___
|
||||||
// / _ \| '_| _| / _| / -_)
|
// / _ \| '_| _| / _| / -_)
|
||||||
|
@ -435,6 +478,28 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
||||||
$builder->produce('entity_label')
|
$builder->produce('entity_label')
|
||||||
->map('entity', $builder->fromParent())
|
->map('entity', $builder->fromParent())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$registry->addFieldResolver('Showroom', 'email',
|
||||||
|
$builder->produce('property_path')
|
||||||
|
->map('type', $builder->fromValue('entity:taxonomy_term'))
|
||||||
|
->map('value', $builder->fromParent())
|
||||||
|
->map('path', $builder->fromValue('field_public_email.value'))
|
||||||
|
);
|
||||||
|
|
||||||
|
$registry->addFieldResolver('Showroom', 'address',
|
||||||
|
$builder->produce('property_path')
|
||||||
|
->map('type', $builder->fromValue('entity:taxonomy_term'))
|
||||||
|
->map('value', $builder->fromParent())
|
||||||
|
->map('path', $builder->fromValue('field_public_address'))
|
||||||
|
);
|
||||||
|
|
||||||
|
$registry->addFieldResolver('Showroom', 'phone',
|
||||||
|
$builder->produce('property_path')
|
||||||
|
->map('type', $builder->fromValue('entity:taxonomy_term'))
|
||||||
|
->map('value', $builder->fromParent())
|
||||||
|
->map('path', $builder->fromValue('field_public_phone.value'))
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// _ _ _
|
// _ _ _
|
||||||
|
@ -626,7 +691,6 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ___
|
// ___
|
||||||
// / __|___ _ __ _ __ __ _ _ _ _ _
|
// / __|___ _ __ _ __ __ _ _ _ _ _
|
||||||
// | (__/ _ \ ' \| '_ \/ _` | ' \ || |
|
// | (__/ _ \ ' \| '_ \/ _` | ' \ || |
|
||||||
|
@ -655,6 +719,12 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
||||||
->map('entity', $builder->fromParent())
|
->map('entity', $builder->fromParent())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$registry->addFieldResolver('Company', 'description',
|
||||||
|
$builder->callback(function($parent, $args){
|
||||||
|
return $parent->getDescription();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
// TODO: property_path helper
|
// TODO: property_path helper
|
||||||
// $props = [
|
// $props = [
|
||||||
// [
|
// [
|
||||||
|
@ -721,8 +791,19 @@ class MaterioSchemaExtension extends SdlSchemaExtensionPluginBase {
|
||||||
->map('path', $builder->fromValue('field_public_address'))
|
->map('path', $builder->fromValue('field_public_address'))
|
||||||
);
|
);
|
||||||
|
|
||||||
// field_infos_from_company
|
$registry->addFieldResolver('Company', 'phone',
|
||||||
// field_public_phone
|
$builder->produce('property_path')
|
||||||
|
->map('type', $builder->fromValue('entity:taxonomy_term'))
|
||||||
|
->map('value', $builder->fromParent())
|
||||||
|
->map('path', $builder->fromValue('field_public_phone.value'))
|
||||||
|
);
|
||||||
|
|
||||||
|
$registry->addFieldResolver('Company', 'infos',
|
||||||
|
$builder->produce('property_path')
|
||||||
|
->map('type', $builder->fromValue('entity:taxonomy_term'))
|
||||||
|
->map('value', $builder->fromParent())
|
||||||
|
->map('path', $builder->fromValue('field_infos_from_company.value'))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue