|
5 | 5 | from graphql.pyutils import dedent |
6 | 6 | from graphql.type import ( |
7 | 7 | GraphQLArgument, |
| 8 | + GraphQLBoolean, |
8 | 9 | GraphQLDirective, |
9 | 10 | GraphQLEnumType, |
10 | 11 | GraphQLEnumValue, |
11 | 12 | GraphQLField, |
| 13 | + GraphQLFloat, |
12 | 14 | GraphQLID, |
13 | 15 | GraphQLInputField, |
14 | 16 | GraphQLInputObjectType, |
| 17 | + GraphQLInt, |
15 | 18 | GraphQLInterfaceType, |
16 | 19 | GraphQLList, |
17 | 20 | GraphQLNonNull, |
|
30 | 33 | specified_directives, |
31 | 34 | validate_schema, |
32 | 35 | ) |
33 | | -from graphql.utilities import extend_schema, print_schema |
| 36 | +from graphql.utilities import build_schema, extend_schema, print_schema |
34 | 37 |
|
35 | 38 | # Test schema. |
36 | 39 |
|
@@ -210,6 +213,54 @@ def extends_objects_by_adding_new_fields(): |
210 | 213 | query_type = assert_object_type(extended_schema.get_type("Query")) |
211 | 214 | assert query_type.fields["foo"].type == foo_type |
212 | 215 |
|
| 216 | + def extends_objects_with_standard_type_fields(): |
| 217 | + schema = build_schema( |
| 218 | + """ |
| 219 | + type Query { |
| 220 | + str: String |
| 221 | + } |
| 222 | + """ |
| 223 | + ) |
| 224 | + |
| 225 | + # Only String and Boolean are used by introspection types |
| 226 | + assert schema.get_type("Int") is None |
| 227 | + assert schema.get_type("Float") is None |
| 228 | + assert schema.get_type("String") is GraphQLString |
| 229 | + assert schema.get_type("Boolean") is GraphQLBoolean |
| 230 | + assert schema.get_type("ID") is None |
| 231 | + |
| 232 | + extend_ast = parse( |
| 233 | + """ |
| 234 | + extend type Query { |
| 235 | + bool: Boolean |
| 236 | + } |
| 237 | + """ |
| 238 | + ) |
| 239 | + extended_schema = extend_schema(schema, extend_ast) |
| 240 | + |
| 241 | + assert extended_schema.get_type("Int") is None |
| 242 | + assert extended_schema.get_type("Float") is None |
| 243 | + assert extended_schema.get_type("String") is GraphQLString |
| 244 | + assert extended_schema.get_type("Boolean") is GraphQLBoolean |
| 245 | + assert extended_schema.get_type("ID") is None |
| 246 | + |
| 247 | + extend_twice_ast = parse( |
| 248 | + """ |
| 249 | + extend type Query { |
| 250 | + int: Int |
| 251 | + float: Float |
| 252 | + id: ID |
| 253 | + } |
| 254 | + """ |
| 255 | + ) |
| 256 | + extended_twice_schema = extend_schema(schema, extend_twice_ast) |
| 257 | + |
| 258 | + assert extended_twice_schema.get_type("Int") is GraphQLInt |
| 259 | + assert extended_twice_schema.get_type("Float") is GraphQLFloat |
| 260 | + assert extended_twice_schema.get_type("String") is GraphQLString |
| 261 | + assert extended_twice_schema.get_type("Boolean") is GraphQLBoolean |
| 262 | + assert extended_twice_schema.get_type("ID") is GraphQLID |
| 263 | + |
213 | 264 | def extends_enums_by_adding_new_values(): |
214 | 265 | extended_schema = extend_test_schema( |
215 | 266 | """ |
|
0 commit comments