thecodingmachine / graphqlite

Use PHP Attributes/Annotations to declare your GraphQL API

Home Page:https://graphqlite.thecodingmachine.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Modify response before returning?

michilehr opened this issue · comments

Hi,

is it possible to modify a response before sending?

Given I have a Configuration with a name that differs from language to language (de and en).

/**
 * @Type()
 */
class Configuration
{
    private string $name;
    
    public function getName(): ?string
    {
        return $this->name;
    }
}

Now I want to query for the name...

query {
  configurations {
	name
  }
} 

... and the response should look like this:

{
  "data": {
    "configurations": {
      "de": {
        "name": "config de"
      },
      "en": {
        "name": "config en"
      }
    }
  }
}

Would this even be valid by the GraphQL specification?

Thanks for your help!