cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to create integration tests for GraphQL

Trying to create integration tests for GraphQL

Hey,

 

I'm trying to create integration tests for some GraphQL endpoints.

 

To test the configuration, I created this very simple test case, but even this simple query is not working. 

    public function testProducts() {
$query = <<<QUERY
{
products(filter: {sku: {eq: "outfit"}}) {
items {
name
sku
url_key
stock_status
}
}
}
QUERY;

$response = $this->graphQlRequest->send($query);
$responseData = $this->json->unserialize($response->getContent());

$this->assertArrayNotHasKey('errors', $responseData);
}

 The error im getting is:

Field "sku" is not defined by type ProductAttributeFilterInput.

If i execute the same query outside of the integration test everything works fine.

 

Any idea how i can get this working?