Skip to content

Conversation

jotwea
Copy link
Contributor

@jotwea jotwea commented Jan 25, 2023

Q A
Branch? 3.1
Tickets #...
License MIT
Doc PR none

I faced problems in GraphQL queries when the field that should be queried is an Enum. This leads to errors because the Type could not be found.

enum_types

Enums are stored with their name and the suffix Enum in the types container. So I added another case to TypesContainer:get method and everything works like a charm.

@alanpoulain
Copy link
Member

I don't think it is the right fix, since the enum type is already added here:

$this->typesContainer->set($enumKey, $enumType);

Please add a Behat test showing your issue.

@jotwea
Copy link
Contributor Author

jotwea commented Jan 25, 2023

This is exactly the code that sets the enum to the types container. The enumKey that is used here is built from the enum name and the suffix Enum as i mentioned. So there has to be a similar code on the reading side that will add the Enum suffix before the get will be done. Maybe you are right and I have not found the best place to apply this. But I found no other place where to handle this - do you have a hint for me?

I am not used to work with Behat, but will try to add a test for it.

@jotwea
Copy link
Contributor Author

jotwea commented Jan 25, 2023

So I tried my best for the moment @alanpoulain and changed the current behat test scenario to demonstrate what happens if the Enum has not an Enum suffix in its name. This is just for demonstrating the behaviour. If you revert my changes in TypesContainer you can see that the mutation tests fail because the gender value is not in the reponse. With them the test is OK.

Of course my last commit needs to be reverted and we have to design a proper test case for this scenario. I am waiting for your response and please give me some advices how you would expect that I should create a proper test scenario. Should we just add another field with an enum to the Person?

@alanpoulain
Copy link
Member

Thanks for the changes, I didn't understand the enum you use had not the Enum suffix.
The PR #5369 should solve your issue properly.

@alanpoulain
Copy link
Member

I'm closing this PR, the patch will be available for 3.1.1. Thank you @jotwea.

@jotwea jotwea deleted the bugfix/enum branch October 13, 2023 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants