|
1 | 1 | package graphql.i18n |
2 | 2 |
|
3 | 3 | import graphql.AssertException |
| 4 | +import graphql.ExecutionInput |
| 5 | +import graphql.TestUtil |
4 | 6 | import graphql.i18n.I18n.BundleType |
5 | 7 | import spock.lang.Specification |
6 | 8 |
|
@@ -71,6 +73,49 @@ class I18nTest extends Specification { |
71 | 73 | message == "Validierungsfehler ({0}) : Type definition '{1}' ist nicht ausführbar" |
72 | 74 | } |
73 | 75 |
|
| 76 | + def "integration test of valid messages"() { |
| 77 | + def sdl = """ |
| 78 | + type Query { |
| 79 | + field(arg : Int) : Subselection |
| 80 | + } |
| 81 | + |
| 82 | + type Subselection { |
| 83 | + name : String |
| 84 | + } |
| 85 | + """ |
| 86 | + def graphQL = TestUtil.graphQL(sdl).build() |
| 87 | + |
| 88 | + |
| 89 | + when: |
| 90 | + def locale = new Locale("en", "IN") |
| 91 | + def ei = ExecutionInput.newExecutionInput().query("query missingSubselectionQ { field(arg : 1) }") |
| 92 | + .locale(locale) |
| 93 | + .build() |
| 94 | + def er = graphQL.execute(ei) |
| 95 | + then: |
| 96 | + !er.errors.isEmpty() |
| 97 | + er.errors[0].message == "Validation error (SubselectionRequired@[field]) : Subselection required for type 'Subselection' of field 'field'" |
| 98 | + |
| 99 | + when: |
| 100 | + locale = Locale.getDefault() |
| 101 | + ei = ExecutionInput.newExecutionInput().query("query missingSubselectionQ { field(arg : 1) }") |
| 102 | + .locale(locale) |
| 103 | + .build() |
| 104 | + er = graphQL.execute(ei) |
| 105 | + then: |
| 106 | + !er.errors.isEmpty() |
| 107 | + er.errors[0].message == "Validation error (SubselectionRequired@[field]) : Subselection required for type 'Subselection' of field 'field'" |
| 108 | + |
| 109 | + when: |
| 110 | + // no locale - it should default |
| 111 | + ei = ExecutionInput.newExecutionInput().query("query missingSubselectionQ { field(arg : 1) }") |
| 112 | + .build() |
| 113 | + er = graphQL.execute(ei) |
| 114 | + then: |
| 115 | + !er.errors.isEmpty() |
| 116 | + er.errors[0].message == "Validation error (SubselectionRequired@[field]) : Subselection required for type 'Subselection' of field 'field'" |
| 117 | + } |
| 118 | + |
74 | 119 | static def assertBundleStaticShape(ResourceBundle bundle) { |
75 | 120 | def enumeration = bundle.getKeys() |
76 | 121 | while (enumeration.hasMoreElements()) { |
|
0 commit comments