Skip to content

Conversation

@dondonz
Copy link
Member

@dondonz dondonz commented Sep 4, 2022

Fixing up tests involving coercing, applied directives, applied directive arguments


/**
* The Coercing interface is used by {@link graphql.schema.GraphQLScalarType}s to parse and serialise object values.
* The Coercing interface is used by {@link graphql.schema.GraphQLScalarType}s to parse and serialize object values.
Copy link
Member Author

@dondonz dondonz Sep 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping it consistent, as much as it pains me to use z here

@@ -1,84 +0,0 @@
package graphql
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's hard to find tests with file names like "Issue 296". Moving tests in generic file names to a better home.

In this case, the test file for Introspection.

GraphQLObjectType getType(TypeResolutionEnvironment env) {
assert env.getField().getName() == "foo"
assert env.getFieldType() == env.getSchema().getType("BarInterface")
assert env.getContext() == "Context"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a dedicated deprecated test for this already

@bbakerman bbakerman merged commit 96f5bf7 into master Sep 4, 2022

then:
values['arg'] == 'hello'
values['arg'] == [inputField: 'hello']
Copy link
Member Author

@dondonz dondonz Sep 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this is a deliberate change - a string result changed to a map.

This is why defaultValue is deprecated, it didn't pick up that the default value type was wrong! 😁

then:
queryTypeFields == [[name: "inA"], [name: "inB"], [name: "inC"]]
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied from "Issue 296" test file. Giving it a better home here in this IntrospectionTest file

@@ -1,16 +1,16 @@
package graphql
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving tests out of generically named files like "Issue 2001" and into a better home.

In this case, an Applied Directive Argument file


def "test non-list value for a list argument of a directive"() {
class GraphQLAppliedDirectiveArgumentTest extends Specification {
def "test non-list value for a list argument of a directive - issue 2001"() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've kept the "issue 2001" in the test name in case someone wants to refer back to it

.type(GraphQLString)
.withDirective(newDirective().name("directive3"))
.value("VALUE")
.value("VALUE") // Retain deprecated for test coverage
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecated GraphQLArgument methods live in this test file

schema.getSchemaDirective("d1").name == "d1"
schema.getSchemaDirectiveByName().keySet() == ["d1"] as Set
schema.getSchemaAppliedDirective("d1").name == "d1"
schema.getAllSchemaAppliedDirectivesByName().keySet() == ["d1", "dr"] as Set
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behaviour slightly changed - the previous method only included non-repeatable directives. The new one includes non-repeatable and repeatable, hence the assert change

def fooDirective = field.getDirective("foo")
fooDirective.arguments.collect { it.name }.sort() == ["arg1", "arg2"]
fooDirective.arguments.collect { GraphQLArgument.getArgumentValue(it) }.sort() == ["arg2Value", "fooArg1Value",]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These deprecated methods are tested elsewhere

@dondonz dondonz deleted the deprecation-drive-2 branch September 4, 2022 02:26
@dondonz dondonz added the not release related changes which are not released (for example unit tests or docs) label Sep 6, 2022
@dondonz dondonz added this to the 20.0 milestone Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

not release related changes which are not released (for example unit tests or docs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants