Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-5329: Fixed empty fields resolving #134

Merged
merged 2 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/GraphQL/Resolver/DomainContentResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,12 @@ public function resolveDomainFieldValue(Content $content, $fieldDefinitionIdenti
return Field::fromField($content->getField($fieldDefinitionIdentifier, $args['language'] ?? null));
}

public function resolveDomainRelationFieldValue(Field $field, $multiple = false)
public function resolveDomainRelationFieldValue(?Field $field, $multiple = false)
{
if ($field === null) {
return null;
}

$destinationContentIds = $this->getContentIds($field);

if (empty($destinationContentIds) || array_key_exists(0, $destinationContentIds) && null === $destinationContentIds[0]) {
Expand Down
6 changes: 5 additions & 1 deletion src/GraphQL/Resolver/ImageAssetFieldResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ public function __construct(iterable $strategies)
}
}

public function resolveDomainImageAssetFieldValue(Field $field): ?Field
public function resolveDomainImageAssetFieldValue(?Field $field): ?Field
{
if ($field === null) {
return null;
}

$destinationContentId = $field->value->destinationContentId;

if ($destinationContentId === null) {
Expand Down
6 changes: 5 additions & 1 deletion src/GraphQL/Resolver/SelectionFieldResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ public function __construct(
$this->domainContentResolver = $domainContentResolver;
}

public function resolveSelectionFieldValue(Field $field, Content $content)
public function resolveSelectionFieldValue(?Field $field, Content $content)
{
if ($field === null) {
return null;
}

$fieldDefinition = $this
->contentTypeLoader->load($content->contentInfo->contentTypeId)
->getFieldDefinition($field->fieldDefIdentifier);
Expand Down
14 changes: 7 additions & 7 deletions src/Resources/config/default_settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ parameters:
ezplatform_graphql.schema.content.mapping.field_definition_type:
ezauthor:
value_type: "[AuthorFieldValue]"
value_resolver: 'field.authors'
value_resolver: 'field !== null ? field.authors : null'
input_type: '[AuthorInput]'
ezbinaryfile:
definition_type: BinaryFieldDefinition
Expand All @@ -13,19 +13,19 @@ parameters:
ezboolean:
definition_type: CheckboxFieldDefinition
value_type: Boolean
value_resolver: 'field.bool'
value_resolver: 'field !== null ? field.bool : null'
input_type: Boolean
ezcountry:
definition_type: CountryFieldDefinition
value_type: String
input_type: '[String]'
ezdate:
value_type: DateTime
value_resolver: 'field.date'
value_resolver: 'field !== null ? field.date : null'
input_type: DateFieldInput
ezdatetime:
value_type: DateTime
value_resolver: 'field.value'
value_resolver: 'field !== null ? field.value : null'
input_type: DateFieldInput
ezemail:
value_type: String
Expand All @@ -35,7 +35,7 @@ parameters:
ezfloat:
definition_type: FloatFieldDefinition
value_type: Float
value_resolver: 'field.value'
value_resolver: 'field !== null ? field.value : null'
input_type: Float
ezgmaplocation:
value_type: MapLocationFieldValue
Expand All @@ -50,11 +50,11 @@ parameters:
ezinteger:
definition_type: IntegerFieldDefinition
value_type: Int
value_resolver: 'field.value'
value_resolver: 'field !== null ? field.value : null'
input_type: Int
ezkeyword:
value_type: '[String]'
value_resolver: 'field.values'
value_resolver: 'field !== null ? field.values : null'
input_type: '[String]'
ezmedia:
definition_type: MediaFieldDefinition
Expand Down