Mutations
In GraphQLite, mutations are created like queries.
To create a mutation, you must annotate a method in a controller with the @Mutation
annotation.
For instance:
- PHP 8
- PHP 7
namespace App\Controller;
use TheCodingMachine\GraphQLite\Annotations\Mutation;
class ProductController
{
#[Mutation]
public function saveProduct(int $id, string $name, ?float $price = null): Product
{
// Some code that saves a product.
}
}
namespace App\Controller;
use TheCodingMachine\GraphQLite\Annotations\Mutation;
class ProductController
{
/**
* @Mutation
*/
public function saveProduct(int $id, string $name, ?float $price = null): Product
{
// Some code that saves a product.
}
}