drupal-graphql / drupal-graphql/graphql

Support Request - Implement PhpUnit test for a create mutation with Upload file fields

Open
#1,146 0 comments 0 reactions 0 assignees View on GitHub
4.x question
Dominant language
PHP
Stars
287
Forks
198
PR merge metrics
No merged PRs in 30d

Description

Hello all,

I'd like to ask your help with a PhpUnit test I'm writing for a create mutation that has an Upload! field argument.

Here is the mutation definition:
```
/**
* A mutation responsible for creating an employer node.
*
* @GraphQLMutation(
* id = "create_employer",
* secure = true,
* name = "createEmployer",
* type = "EntityCrudOutput",
* arguments = {
* "input" = "CreateEmployerInput"
* }
* )
*/
```

Where CreateEmployerInput is:
```
/**
* @GraphQLInputType(
* id = "create_employer_input",
* name = "CreateEmployerInput",
* fields = {
* "title" = "String!",
* "field_advertiser_name" = "String!",
* "field_logo" = "FileUploadInput",
* }
* )
*/
```

In my PHP unit test I'm using this:
```
// Execute mutation and assert result.
$this->assertResults($this->getQueryFromFile('mutations/create_employer_mutation.gql'), [], [
'creteEmployer' => [
'errors' => [],
'violations' => [],
'entity' => [
'entityLabel' => 'Employer test',
],
],
], $metadata);
```

And the mutation graphql looks like this:

```
mutation {
createEmployer(input:{
title: "Employer test",
field_advertiser_name:"Employer test adv name",
field_logo:"..",
}) {
violations {
path
message
}
errors
entity {
entityLabel
}
}
}
```

Does anyone know how can I test the `field_logo`?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.