Hi I'm trying to create a resolver that returns a JSON, I use this library with custom scalars https://github.com/mll-lab/graphql-php-scalars
I'm using the JSON scalar like this:
schema.graphql:
input CustomInput {
field1: String!
field2: String!
}
type Mutation {
getJson(data: CustomInput): JSON @field(resolver: "App\\GraphQL\\Mutations\\TestResolver@index")
}
TestResolver.php
public function index($rootValue, array $args, GraphQLContext $context, ResolveInfo $resolveInfo)
{
$data = array('msg'=>'hellow world', 'trueorfalse'=>true);
return \Safe\json_encode($data);
}
GraphQL Playgroud
mutation{
getJson(data: { field1: "foo", field2: "bar" })
}
------------ response------------
{
"data": {
"getJson": "\"{\\\"msg\\\":\\\"hello world\\\",\\\"trueorfalse\\\":true}\""
}
}
as you can see it returns a string, instead of a JSON... what am I doing wrong?