@@ -285,52 +285,51 @@ class MethodFieldResolverTest {
285285 }
286286
287287 @Test
288- fun `should warn when an argument is passed to a context parameter` () {
288+ fun `should warn when a resolver method is missing a parameter for an argument ` () {
289289 val (_, warnings) = withWarnings {
290290 SchemaParser .newParser()
291291 .schemaString(
292292 """
293293 type Query {
294- context (id: ID!, persist : Boolean!): String
295- graphQLContext(persist : Boolean, id: ID ): String
294+ user (id: ID!, active : Boolean!): String
295+ users(active : Boolean, first: Int ): String
296296 image: Image
297- input(input: Input ): String
298- extra(persist : Boolean): String
297+ search(filter: Filter ): String
298+ count(active : Boolean): String
299299 }
300300
301301 type Image {
302302 thumbnail(size: Int): String
303303 }
304304
305- input Input {
306- value : String
305+ input Filter {
306+ name : String
307307 }
308308 """ )
309- .resolvers(ContextParameterQuery (), ImageResolver ())
309+ .resolvers(MissingParameterQuery (), ImageResolver ())
310310 .options(SchemaParserOptions .newOptions().contextClass(Map ::class ).build())
311311 .build()
312312 .makeExecutableSchema()
313313 }
314314
315- val query = ContextParameterQuery ::class .java.name
315+ val query = MissingParameterQuery ::class .java.name
316316 assertEquals(warnings, listOf (
317- " Field 'Query.context' passes its argument 'persist: Boolean!' to the java.util.Map parameter of $query .context, so the field " +
318- " fails or gets null for that parameter. Declare one parameter per argument, in order, before the Map parameter." ,
319- " Field 'Query.graphQLContext' passes its argument 'persist: Boolean' to the graphql.GraphQLContext parameter of " +
320- " $query .graphQLContext, so the field fails or gets null for that parameter. Declare one parameter per argument, in order, " +
321- " before the GraphQLContext parameter." ,
322- " Field 'Image.thumbnail' passes its argument 'size: Int' to the graphql.schema.DataFetchingEnvironment parameter of " +
323- " ${ImageResolver ::class .java.name} .thumbnail, so the field fails or gets null for that parameter. Declare one parameter per " +
324- " argument, in order, before the DataFetchingEnvironment parameter."
317+ " Field 'Query.user' has no parameter for its argument 'active: Boolean!' in $query .user, so the Map parameter gets the " +
318+ " argument instead. Add a parameter for each argument, in order, before the Map parameter." ,
319+ " Field 'Query.users' has no parameter for its argument 'active: Boolean' in $query .users, so the GraphQLContext parameter " +
320+ " gets the argument instead. Add a parameter for each argument, in order, before the GraphQLContext parameter." ,
321+ " Field 'Image.thumbnail' has no parameter for its argument 'size: Int' in ${ImageResolver ::class .java.name} .thumbnail, so the " +
322+ " DataFetchingEnvironment parameter gets the argument instead. Add a parameter for each argument, in order, before the " +
323+ " DataFetchingEnvironment parameter."
325324 ))
326325 }
327326
328- class ContextParameterQuery : GraphQLQueryResolver {
329- fun context (id : String , context : Map <String , Any >) = " $id $context "
330- fun graphQLContext (context : GraphQLContext ? , id : String ? ) = " $context $id "
327+ class MissingParameterQuery : GraphQLQueryResolver {
328+ fun user (id : String , context : Map <String , Any >) = " $id $context "
329+ fun users (context : GraphQLContext ? , first : Int ? ) = " $context $first "
331330 fun image () = Image ()
332- fun input ( input : Map <String , Any >? ) = input .toString()
333- fun extra ( persist : Boolean? , context : Map <String , Any >) = " $persist $context "
331+ fun search ( filter : Map <String , Any >? ) = filter .toString()
332+ fun count ( active : Boolean? , context : Map <String , Any >) = " $active $context "
334333 }
335334
336335 class Image
0 commit comments