dgs-framework icon indicating copy to clipboard operation
dgs-framework copied to clipboard

bug: scalars automatically registered by `graphql-dgs-extended-scalars` are not registered in test environment

Open nallwhy opened this issue 3 years ago • 2 comments

Expected behavior

Below are my schema and test code.

scalar Long

type Query {
  ping: Pong!
}

type Pong {
  long: Long!
}
@SpringBootTest(
    classes = [DgsAutoConfiguration::class, PingQuery::class]
)
class PingQueryTest {
    @Autowired
    lateinit var dgsQueryExecutor: DgsQueryExecutor

    @Test
    fun run() {
        val query = """
        query {
          ping {
            long
          }
        }
        """

        val result = dgsQueryExecutor.execute(query)
        ...
    }
}

That ping query works well in dev environment because graphql-dgs-extended-scalars automatically registers many scalars including Long. So I expect the test to pass.

Actual behavior

The test fails because Long scalar does not exist.

***************************
APPLICATION FAILED TO START
***************************

Description:

There are problems with the GraphQL Schema:
	 * There is no scalar implementation for the named  'Long' scalar type

Steps to reproduce

Note: A test case would be highly appreciated, but we understand that's not always possible

nallwhy avatar Aug 16 '22 09:08 nallwhy

@nallwhy Leaving a comment here since I am not certain if this is a bug or intended behavior due to the configuration being different beans. It would be nice if the DgsAutoConfiguration.class stood up extended scalars, but there is an easy workaround of adding the DgsExtendedScalarsAutoConfiguration.class to your @SpringBootTest annotation.

lbusch25 avatar Oct 11 '22 16:10 lbusch25

Thanks for the response to this issue. This is intended behavior, since extended scalars are an add-on feature and not available out of the box. The intention is for the user to specify any classes explicitly for @SpringBootTest.

On Tue, Oct 11, 2022 at 9:40 AM Lawson Busch @.***> wrote:

@nallwhy https://github.com/nallwhy Leaving a comment here since I am not certain if this is a bug or intended behavior due to the configuration being different beans. It would be nice if the DgsAutoConfiguration.class stood up extended scalars, but there is an easy workaround of adding the DgsExtendedScalarsAutoConfiguration.class to your @SpringBootTest annotation.

— Reply to this email directly, view it on GitHub https://github.com/Netflix/dgs-framework/issues/1190#issuecomment-1274979927, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ5JPXNMGJG4W27M2RD7CMTWCWJ6NANCNFSM56VDRZGA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

srinivasankavitha avatar Oct 11 '22 16:10 srinivasankavitha