How to fixed GraphQl Fields conflicting types. Use different aliases on the fields to fetch result?

GraphQl aliases are used to prevent errors of GraphQL fields conflict type in the response of the query.

Using Aliases in the query to fix the issue of the conflicting type of GraphQl while same type of  arguments are used in a query.

Let’s say a real example to understand these aliases.

Here CustomizableFieldOption and CustomizableDropDownOption both type are implementing the same interface called CustomizableOptionInterface.

Henceforth when you try to execute the query, you will face an error called,

Here we will update the query to resolve the above error by adding aliases to the value parameter.

You can add aliases like aliasName: fieldName
This format is more readable and understands easily in the query by adding alias like below,

  • For an example of adding an alias to the field name,

In the first type, We are adding textField as Alias to the value argument,

Second type by adding a dropDown as an alias to the value argument,

The final query to fetch with products by filtering SKU,

The final result response without error: