GraphQL - типы объединения, дающие ошибку, не удалось найти класс для этого имени типа

В моем файле схемы GraphQL я пытаюсь добавить такой тип объединения:

type CoOverrides {
    coId: String
    type: String
}

type SoOverrides {
    soId: String
    freeInterval: String
}

union CoOrSoOverrides = CoOverrides | SoOverrides

Затем я назначаю это своему типу следующим образом:

type Campaign {
    id: ID!
    title: String
    overrides: [CoOrSoOverrides]
}

Однако при запуске сервера graphql я продолжаю получать ошибку:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.coxautodev.graphql.tools.SchemaParser]: Factory method 'schemaParser' threw exception; 
nested exception is com.coxautodev.graphql.tools.SchemaClassScannerError: 
Object type 'CoOverrides' is a member of a known union, but no class could be found for that type name.  Please pass a class for type 'CoOverrides' in the parser's dictionary.

Что это такое и как добавить этот класс в словарь парсера?

Любая помощь приветствуется.

Спасибо.

1 ответ

Как в сообщении об ошибке - пройти CoOverrides класс в словарь.

@Configuration
public class SchemaParserConfig {

    @Bean
    public SchemaParserDictionary schemaParserDictionary() {
        return new SchemaParserDictionary()
                .add(CoOverrides.class);
    }

}
Другие вопросы по тегам