graphql: Include default argument values in introspection tests
@@ -45,8 +45,9 @@ impl Resolver for MockResolver {
fn mock_schema() -> Schema {
Schema::parse(
"
- scalar String
scalar ID
+ scalar Int
+ scalar String
directive @language(
language: String = \"English\"
@@ -73,12 +74,13 @@ fn mock_schema() -> Schema {
}
input User_filter {
- name_eq: String,
+ name_eq: String = \"default name\",
name_not: String,
}
type Query @entity {
allUsers(orderBy: User_orderBy, filter: User_filter): [User!]
+ anyUserWithAge(age: Int = 99): User
User: User
}
",
@@ -112,6 +114,17 @@ fn expected_mock_schema_introspection() -> q::Value {
("possibleTypes", q::Value::Null),
]);
+ let int_type = object_value(vec![
+ ("kind", q::Value::Enum("SCALAR".to_string())),
+ ("name", q::Value::String("Int".to_string())),
+ ("description", q::Value::Null),
+ ("fields", q::Value::Null),
+ ("inputFields", q::Value::Null),
+ ("enumValues", q::Value::Null),
+ ("interfaces", q::Value::Null),
+ ("possibleTypes", q::Value::Null),
+ ]);
+
let role_type = object_value(vec![
("kind", q::Value::Enum("ENUM".to_string())),
("name", q::Value::String("Role".to_string())),
@@ -219,7 +232,10 @@ fn expected_mock_schema_introspection() -> q::Value {
object_value(vec![
("name", q::Value::String("name_eq".to_string())),
("description", q::Value::Null),
- ("defaultValue", q::Value::Null),
+ (
+ "defaultValue",
+ q::Value::String("\"default name\"".to_string()),
+ ),
(
"type",
object_value(vec![
@@ -403,6 +419,36 @@ fn expected_mock_schema_introspection() -> q::Value {
("isDeprecated", q::Value::Boolean(false)),
("deprecationReason", q::Value::Null),
]),
+ object_value(vec![
+ ("name", q::Value::String("anyUserWithAge".to_string())),
+ ("description", q::Value::Null),
+ (
+ "args",
+ q::Value::List(vec![object_value(vec![
+ ("defaultValue", q::Value::String("99".to_string())),
+ ("description", q::Value::Null),
+ ("name", q::Value::String("age".to_string())),
+ (
+ "type",
+ object_value(vec![
+ ("kind", q::Value::Enum("SCALAR".to_string())),
+ ("name", q::Value::String("Int".to_string())),
+ ("ofType", q::Value::Null),
+ ]),
+ ),
+ ])]),
+ ),
+ (
+ "type",
+ object_value(vec![
+ ("kind", q::Value::Enum("OBJECT".to_string())),
+ ("name", q::Value::String("User".to_string())),
+ ("ofType", q::Value::Null),
+ ]),
+ ),
+ ("isDeprecated", q::Value::Boolean(false)),
+ ("deprecationReason", q::Value::Null),
+ ]),
object_value(vec![
("name", q::Value::String("User".to_string())),
("description", q::Value::Null),
@@ -428,6 +474,7 @@ fn expected_mock_schema_introspection() -> q::Value {
let expected_types = q::Value::List(vec![
id_type,
+ int_type,
node_type,
query_type,
role_type,
