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

В моем файле схемы 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.

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

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

Спасибо.


person userMod2    schedule 17.01.2020    source источник


Ответы (1)


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

@Configuration
public class SchemaParserConfig {

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

}
person Tomasz Fijałkowski    schedule 24.07.2020