|
3 | 3 |
|
4 | 4 | use GraphQL\GraphQL; |
5 | 5 | use GraphQL\Language\AST\EnumTypeDefinitionNode; |
6 | | -use GraphQL\Language\AST\InputObjectTypeDefinitionNode; |
7 | 6 | use GraphQL\Language\AST\InterfaceTypeDefinitionNode; |
8 | 7 | use GraphQL\Language\AST\ObjectTypeDefinitionNode; |
9 | | -use GraphQL\Language\AST\TypeNode; |
10 | 8 | use GraphQL\Language\Parser; |
11 | 9 | use GraphQL\Language\Printer; |
12 | 10 | use GraphQL\Type\Definition\EnumType; |
13 | 11 | use GraphQL\Type\Definition\ObjectType; |
14 | 12 | use GraphQL\Utils\BuildSchema; |
15 | 13 | use GraphQL\Utils\SchemaPrinter; |
16 | | - |
17 | 14 | use GraphQL\Type\Definition\Directive; |
18 | | -use GraphQL\Type\Definition\EnumValueDefinition; |
19 | 15 |
|
20 | 16 | class BuildSchemaTest extends \PHPUnit_Framework_TestCase |
21 | 17 | { |
@@ -1119,4 +1115,44 @@ interface Hello { |
1119 | 1115 | $this->assertArrayHasKey('Hello', $types); |
1120 | 1116 | $this->assertArrayHasKey('World', $types); |
1121 | 1117 | } |
| 1118 | + |
| 1119 | + public function testScalarDescription() |
| 1120 | + { |
| 1121 | + $schemaDef = ' |
| 1122 | +# An ISO-8601 encoded UTC date string. |
| 1123 | +scalar Date |
| 1124 | +
|
| 1125 | +type Query { |
| 1126 | + now: Date |
| 1127 | + test: String |
| 1128 | +} |
| 1129 | +'; |
| 1130 | + $q = ' |
| 1131 | +{ |
| 1132 | + __type(name: "Date") { |
| 1133 | + name |
| 1134 | + description |
| 1135 | + } |
| 1136 | + strType: __type(name: "String") { |
| 1137 | + name |
| 1138 | + description |
| 1139 | + } |
| 1140 | +} |
| 1141 | +'; |
| 1142 | + $schema = BuildSchema::build($schemaDef); |
| 1143 | + $result = GraphQL::executeQuery($schema, $q)->toArray(); |
| 1144 | + $expected = ['data' => [ |
| 1145 | + '__type' => [ |
| 1146 | + 'name' => 'Date', |
| 1147 | + 'description' => 'An ISO-8601 encoded UTC date string.' |
| 1148 | + ], |
| 1149 | + 'strType' => [ |
| 1150 | + 'name' => 'String', |
| 1151 | + 'description' => 'The `String` scalar type represents textual data, represented as UTF-8' . "\n" . |
| 1152 | + 'character sequences. The String type is most often used by GraphQL to'. "\n" . |
| 1153 | + 'represent free-form human-readable text.' |
| 1154 | + ] |
| 1155 | + ]]; |
| 1156 | + $this->assertEquals($expected, $result); |
| 1157 | + } |
1122 | 1158 | } |
0 commit comments