Adding attributes to filter product data in GraphQL
Fixing ‘Field X is not defined’ errors
If you encounter an error like:
"Field "sku" is not defined by type ProductAttributeFilterInput.
This indicates the attribute is not enabled for filtering. To resolve this, you can:
-
Set the attribute's Use in Layered Navigation field to Filterable (with results) or Filterable (no results).
This enables the attribute for filtering and provides layered navigation and aggregation data. Setting it to No disables these features. -
Set both the Use in Search and Visible in Advanced Search fields to Yes.
This indexes the attribute for quick and advanced searches, and also enables it for filter navigation. Note: This option does not control layered navigation or aggregation data. If only one of these fields is set to Yes, the attribute will not be filterable unless Use in Layered Navigation is also set to a filterable option.
Source: devdocs.magento.com/guides/v2.4/graphql/custom-filters.html