Skip to content

Commit

Permalink
Merge branch 'master' into benchmark_enf
Browse files Browse the repository at this point in the history
  • Loading branch information
dondonz committed Aug 10, 2022
2 parents b710226 + faf6337 commit dbc0476
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/java/graphql/Directives.java
Expand Up @@ -82,7 +82,7 @@ public class Directives {

public static final GraphQLDirective SkipDirective = GraphQLDirective.newDirective()
.name("skip")
.description("Directs the executor to skip this field or fragment when the `if`'argument is true.")
.description("Directs the executor to skip this field or fragment when the `if` argument is true.")
.argument(newArgument()
.name("if")
.type(nonNull(GraphQLBoolean))
Expand Down
Expand Up @@ -313,7 +313,7 @@ private List<FieldDefinition> createFields(List<Map<String, Object>> fields) {

private void createDeprecatedDirective(Map<String, Object> field, NodeDirectivesBuilder nodeDirectivesBuilder) {
List<Directive> directives = new ArrayList<>();
if ((Boolean) field.get("isDeprecated")) {
if (Boolean.TRUE.equals(field.get("isDeprecated"))) {
String reason = (String) field.get("deprecationReason");
if (reason == null) {
reason = "No longer supported"; // default according to spec
Expand Down
2 changes: 1 addition & 1 deletion src/test/groovy/graphql/Issue2141.groovy
Expand Up @@ -36,7 +36,7 @@ directive @include(
if: Boolean!
) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
"Directs the executor to skip this field or fragment when the `if`'argument is true."
"Directs the executor to skip this field or fragment when the `if` argument is true."
directive @skip(
"Skipped when true."
if: Boolean!
Expand Down
Expand Up @@ -988,4 +988,71 @@ scalar EmployeeRef
scalar EmployeeRef
'''
}

def "copes when isDeprecated is not defined"() {
def input = ''' {
"kind": "OBJECT",
"name": "QueryType",
"description": null,
"fields": [
{
"name": "hero",
"description": null,
"args": [
{
"name": "episode",
"description": "comment about episode\non two lines",
"type": {
"kind": "ENUM",
"name": "Episode",
"ofType": null
},
"defaultValue": null
},
{
"name": "foo",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": "\\"bar\\""
}
],
"type": {
"kind": "INTERFACE",
"name": "Character",
"ofType": null
},
"isDeprecatedISNOTYDEFINED": false,
"deprecationReason": "killed off character"
}
],
"inputFields": null,
"interfaces": [{
"kind": "INTERFACE",
"name": "Query",
"ofType": null
}],
"enumValues": null,
"possibleTypes": null
}
'''
def parsed = slurp(input)

when:
ObjectTypeDefinition objectTypeDefinition = introspectionResultToSchema.createObject(parsed)
def result = printAst(objectTypeDefinition)

then:
result == """type QueryType implements Query {
hero(\"\"\"
comment about episode
on two lines
\"\"\"
episode: Episode, foo: String = \"bar\"): Character
}"""

}
}
14 changes: 7 additions & 7 deletions src/test/groovy/graphql/schema/idl/SchemaPrinterTest.groovy
Expand Up @@ -938,7 +938,7 @@ directive @single on OBJECT
directive @singleField on FIELD_DEFINITION
"Directs the executor to skip this field or fragment when the `if`'argument is true."
"Directs the executor to skip this field or fragment when the `if` argument is true."
directive @skip(
"Skipped when true."
if: Boolean!
Expand Down Expand Up @@ -1079,7 +1079,7 @@ directive @include(
if: Boolean!
) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
"Directs the executor to skip this field or fragment when the `if`'argument is true."
"Directs the executor to skip this field or fragment when the `if` argument is true."
directive @skip(
"Skipped when true."
if: Boolean!
Expand Down Expand Up @@ -1176,7 +1176,7 @@ directive @include(
directive @moreComplex(arg1: String = "default", arg2: Int) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
"Directs the executor to skip this field or fragment when the `if`'argument is true."
"Directs the executor to skip this field or fragment when the `if` argument is true."
directive @skip(
"Skipped when true."
if: Boolean!
Expand Down Expand Up @@ -1241,7 +1241,7 @@ directive @include(
directive @moreComplex(arg1: String = "default", arg2: Int) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
"Directs the executor to skip this field or fragment when the `if`'argument is true."
"Directs the executor to skip this field or fragment when the `if` argument is true."
directive @skip(
"Skipped when true."
if: Boolean!
Expand Down Expand Up @@ -1373,7 +1373,7 @@ directive @include(
if: Boolean!
) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
"Directs the executor to skip this field or fragment when the `if`'argument is true."
"Directs the executor to skip this field or fragment when the `if` argument is true."
directive @skip(
"Skipped when true."
if: Boolean!
Expand Down Expand Up @@ -1875,7 +1875,7 @@ directive @include(
if: Boolean!
) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
"Directs the executor to skip this field or fragment when the `if`'argument is true."
"Directs the executor to skip this field or fragment when the `if` argument is true."
directive @skip(
"Skipped when true."
if: Boolean!
Expand Down Expand Up @@ -2053,7 +2053,7 @@ directive @specifiedBy(
url: String!
) on SCALAR
"Directs the executor to skip this field or fragment when the `if`'argument is true."
"Directs the executor to skip this field or fragment when the `if` argument is true."
directive @skip(
"Skipped when true."
if: Boolean!
Expand Down

0 comments on commit dbc0476

Please sign in to comment.