mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
accept JSON strings for ID values (#384)
<!-- Thank you for submitting this PR! :) --> ## Description Forgot this case in https://github.com/hasura/v3-engine/pull/350 - we should allow strings to be used for GraphQL `ID` values. <!-- Questions to consider answering: 1. What user-facing changes are being made? 2. What are issues related to this PR? (Consider adding `(close #<issue-no>)` to the PR title) 3. What is the conceptual design behind this PR? 4. How can this PR be tested/verified? 5. Does the PR have limitations? 6. Does the PR introduce breaking changes? --> ## Changelog - Add a changelog entry (in the "Changelog entry" section below) if the changes in this PR have any user-facing impact. See [changelog guide](https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide). - If no changelog is required ignore/remove this section and add a `no-changelog-required` label to the PR. ### Product _(Select all products this will be available in)_ - [X] community-edition - [X] cloud <!-- product : end : DO NOT REMOVE --> ### Type <!-- See changelog structure: https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide#structure-of-our-changelog --> _(Select only one. In case of multiple, choose the most appropriate)_ - [ ] highlight - [X] enhancement - [ ] bugfix - [ ] behaviour-change - [ ] performance-enhancement - [ ] security-fix <!-- type : end : DO NOT REMOVE --> ### Changelog entry <!-- - Add a user understandable changelog entry - Include all details needed to understand the change. Try including links to docs or issues if relevant - For Highlights start with a H4 heading (#### <entry title>) - Get the changelog entry reviewed by your team --> Allow JSON strings to be passed for arguments with ID scalar type. <!-- changelog-entry : end : DO NOT REMOVE --> <!-- changelog : end : DO NOT REMOVE --> V3_GIT_ORIGIN_REV_ID: df2a81a891a6aa0af54c9792916e1469b823f769
This commit is contained in:
parent
2ec2444ef3
commit
db87ec1ab8
@ -72,6 +72,7 @@ fn typecheck_inbuilt_type(
|
||||
(open_dds::types::InbuiltType::Int, serde_json::Value::Number(_)) => Ok(()),
|
||||
(open_dds::types::InbuiltType::Float, serde_json::Value::Number(_)) => Ok(()),
|
||||
(open_dds::types::InbuiltType::String, serde_json::Value::String(_)) => Ok(()),
|
||||
(open_dds::types::InbuiltType::ID, serde_json::Value::String(_)) => Ok(()),
|
||||
(open_dds::types::InbuiltType::Boolean, serde_json::Value::Bool(_)) => Ok(()),
|
||||
|
||||
_ => Err(TypecheckError::ScalarTypeMismatch {
|
||||
@ -122,6 +123,15 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
fn id_type() -> subgraph::QualifiedTypeReference {
|
||||
subgraph::QualifiedTypeReference {
|
||||
nullable: false,
|
||||
underlying_type: subgraph::QualifiedBaseType::Named(
|
||||
subgraph::QualifiedTypeName::Inbuilt(open_dds::types::InbuiltType::ID),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
fn array_of(item: subgraph::QualifiedTypeReference) -> subgraph::QualifiedTypeReference {
|
||||
subgraph::QualifiedTypeReference {
|
||||
nullable: false,
|
||||
@ -163,6 +173,14 @@ mod tests {
|
||||
assert_eq!(typecheck_qualified_type_reference(&ty, &value), Ok(()))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_typecheck_id() {
|
||||
let ty = id_type();
|
||||
let value = json!("12312312sdwfdsff123123");
|
||||
|
||||
assert_eq!(typecheck_qualified_type_reference(&ty, &value), Ok(()))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_typecheck_array_of_boolean() {
|
||||
let ty = array_of(boolean_type());
|
||||
|
Loading…
Reference in New Issue
Block a user