We can add categories to posts in WordPress (i.e. using the taxonomy with name "category"). This is already mapped in the GraphQL schema via the PostCategory, associated to a Post entry.
Custom Post Types defined by any theme or plugin (such as "product") can likewise have their own category taxonomy associated to them (such as "product-cat"). As these category taxonomies don't ship their own specific type for the GraphQL schema (that would require an extension via PHP code), these are resolved via the GenericCategory type.
We use fields category and categories to fetch category data, which must indicate which taxonomy they refer to via mandatory field argument taxonomy. The result is of the union type CategoryUnion, which includes entries from either PostCategory or GenericCategory (depending on the entry's taxonomy).
Configuring the queryable category taxonomies permalink
The category taxonomies that can be queried must be explicitly configured. This can be done in 2 places.
In the Schema Configuration applied to the endpoint, by selecting option "Use custom configuration" under "Customize configuration, or use default from Settings?" and then selecting the desired items:
This list contains all the "hierarchical" taxonomies which are associated to queryable custom posts, i.e. those selected in "Included custom post types" in the Settings for "Custom Posts". Each category taxonomy's associated custom post types is shown under (CPT: ...). If your desired category taxonomy does not appear here, make sure that all of its associated custom post types are in that allowlist.
Otherwise, if selecting option "Use configuration from Settings", the value defined under section "Included category taxonomies" in the Settings page for Schema Custom Posts is used: