Open xsist10 opened 5 years ago
Added test
use strict;
use warnings;
use Graph::QL::Schema;
use Graph::QL::Operation;
use Graph::QL::Execution::QueryValidator;
use Test::More;
my $schema = Graph::QL::Schema->new_from_source(q[
type Records {
id : Int!
external_id : Int
}
type Query {
get_records(id : Int = null, external_id : Int = null) : [Records]
}
schema {
query : Query
}
]);
my @queries = (
q[
query TestQuery {
get_records {
id
}
}
],
q[
query TestQuery {
get_records(id: 1) {
id
}
}
],
);
foreach (@queries) {
my $operation = Graph::QL::Operation->new_from_source($_);
# Perform validation first
my $validator = Graph::QL::Execution::QueryValidator->new(
schema => $schema,
operation => $operation,
);
# Check if all the validation steps passed
my $validate = $validator->validate();
my $messages = join("\n", $validator->get_errors());
ok($validate, "Query $_ passes the parameter validation checks properly with messages: $messages.");
}
done_testing();
1;
I think the validation rules are not taking default and nullable parameter configurations into account when validating the query.
I have a schema definition that includes a query that takes two parameters both marked as nullable (no
!
post-fix) and both with the default value set tonull
.The schema looks like this:
When I run the following query:
I get this error Message:
And when I run the following query:
I get this error Message: