Category : graphql

I am using API-Platform with GraphQL. In my database, I had saved value object in JSON but while querying through GraphQL it finally returns empty. I had done the debugging and found that (in vendor directory) at ApiPlatformCoreGraphQlSerializerItemNormalizer class’s function(normalizeCollectionOfRelations) forcefully returns empty array. Below code snippt. /** * {@inheritdoc} */ protected function normalizeCollectionOfRelations(PropertyMetadata $propertyMetadata, ..

Read more

My problem is the security implementation of the entities when consumed through GraphQL, the queries are perfect, they return the necessary data, but the problem occurs when a query is generated and the many-to-one relationship is limited to having a role "ROLE_ADMIN", the query returns the data even when the user has the role "IS_AUTHENTICATED_ANONYMOUSLY" ..

Read more

API Platform version(s) affected: v2.5.7 (symfony v4.4.13 on PHP 7.4) Description I have an Entity with a field typed with a custom type. It works great if the field isn’t null. If there is an item with a null value, it throw a "Resource "DateTime" not found Following that documentation: https://api-platform.com/docs/core/graphql/#custom-types And this one : ..

Read more

API Platform version(s) affected: v2.5.7 (symfony v4.4.13 on PHP 7.4) Description Using serialization groups, I want to show field of a linked resource. For example, a User have an Organization AppEntityUser * @ApiResource( * normalizationContext={"groups"={"User:read"}}, * denormalizationContext={"groups"={"User:write"}}, * graphql={ * "item_query"={"normalization_context"={"groups"={"User:read"}}}, * "collection_query"={"normalization_context"={"groups"={"User:read"}}}, * } * ) [….] /** * @Groups({"User:read"}) * @ORMManyToOne(targetEntity="Organization", inversedBy="users") * ..

Read more

I have a basic Entity in my symfony application: /** * @ApiResource() * @ORMEntity(repositoryClass=CardRepository::class) */ class Card { /** * @ORMId() * @ORMGeneratedValue() * @ORMColumn(type=”integer”) */ private $id; /** * @ORMOneToMany(targetEntity=CardReference::class, mappedBy=”card”, orphanRemoval=true) */ private $cardReferences; /** * @ORMColumn(type=”string”, length=255, nullable=true) */ private $name; As you can see – there is another Entity: CardReference with ..

Read more