0

I'm trying to test my graphQL schema using the DgsQueryExecutor. My GraphQL schema is dynamically created using @DgsCodeRegistry and @DgsTypeDefinitionRegistry.

This is the code for my test

@SpringBootTest
public class DataFetcherRegistryTest {
    @Autowired
    private DgsQueryExecutor dgsQueryExecutor;


    @Test
    public void firstTest(){
        String value = dgsQueryExecutor.executeAndExtractJsonPath(
                "{ catalog { customer { test_attribute }}}",
                "data.catalog.customer.test_attribute");

        assertThat(value).isEqualTo("test-value");
    }
}

I'm getting the following error

Field 'catalog' in type 'Query' is undefined

When the test loads it runs the method annotated with @DgsCodeRegistry but not the method annotated with @DgsTypeDefinitionRegistry. It only cares about the schema loaded from schema.graphql which in my case is empty because I'm creating the schema programmatically.

user3236794
  • 578
  • 1
  • 6
  • 16

0 Answers0