Commit 8a32f3f
Fix MySQL test execution time + Fix DateTime GraphQL input handling (#2265)
## Why make this change?
I discovered another bug while working on this change #2268, which will
be addressed separately.
## What is this change?
- Fixes a bug where GraphQL DateTime input with Timezone (TZ) offset was
not honored.
- e.g. `12-31-2024T12:00:00+03:00` was stored as `12-31-2024T12:00:00`
in the backend database instead of `12-31-2024T09:00:00`
- This bug was discovered because some SupportedTypes tests involving
dates always failed locally but not in the integration test pipeline. My
local machine in UTC-8 while pipelines are UTC. Additionally, some test
input `9999-12-31 23:59:59.9999999` was run for MySql where that value
is an invalid date (max decimal is .499999).
- Fixes false negative (passing) test cases in
**GraphQLSupportedTypesTests** by adding more comprehensive asserts,
updating DataRow test input, and ensuring tests specific to a database
type are correctly executed.
- As a result, MySQL tests in this specific test suite run way faster
(~minutes down to less than 10 seconds because the conclusion of each
data row execution doesn't reset the MySql database contents which takes
a long time via `ResetDbStateAsync()`.)
- Updates test code queries and mutations to include the primary key
(typeid) of the table **type_table** so that tests interact with
determinate records:
```csharp
string gqlQuery = "{ supportedType_by_pk(typeid: " + id + ") { typeid, "
+ field + " } }";
```
- A bug in the test
```csharp
// Old test
[DataRow(TIME_TYPE, "\"23:59:59.9999999\"")]
// Fixed Test
[DataRow(TIME_TYPE, "23:59:59")]
public async Task InsertIntoTypeColumnWithArgument(string type, object value)
```
This test shows as green in main branch. However, looking at the log of
the test, I saw this error:
> GraphQL error: [{"message":"The variable `param` is not compatible
with the type of the current
location.","locations":[{"line":1,"column":65}],"path":["createSupportedType"],"extensions":{"variable":"param","variableType":"Time","locationType":"LocalTime","specifiedBy":"http://spec.graphql.org/October2021/#sec-All-Variable-Usages-are-Allowed"}}]
There are two layers of changes here:
1. TIME_TYPE is technically not a GraphQL data type recognized or
defined by DAB's generated GraphQL schema/ HotChocolate -> LocalTime is.
So when the data row for TIME_TYPE comes in this code resolves the
expected type:
```csharp
private static string TypeNameToGraphQLType(string typeName)
{
return typeName switch
{
DATETIMEOFFSET_TYPE => DATETIME_TYPE,
TIME_TYPE => LOCALTIME_TYPE,
_ => typeName
};
}
```
2. Leaving quotes on the value -> `\"23:59:59.9999999\"` in results in
the error:
> GraphQL error: [{"message":"Unable to deserialize string to
LocalTime","path":["param"]}]
why keep data row as "TIME_TYPE"? well, our test code resolves that type
name not only as the GraphQL type but also as a way to determine which
column in the data source to select which is named time_types. So we'd
need to decouple the GraphQL Data Type value from being used to
determine the SQL table column name.
## How was this tested?
- [x] Integration Tests - Fixed tests in GraphQLSupportedTypesTests
---------
Co-authored-by: Aniruddh Munde <anmunde@microsoft.com>
Co-authored-by: Abhishek Kumar <102276754+abhishekkumams@users.noreply.github.com>
Co-authored-by: Abhishek Kumar <abhishekkuma@microsoft.com>1 parent 689c3e7 commit 8a32f3f
File tree
6 files changed
+326
-79
lines changed- src
- Core/Resolvers/Sql Query Structures
- Service.Tests/SqlTests/GraphQLSupportedTypesTests
6 files changed
+326
-79
lines changedLines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
442 | | - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
443 | 450 | | |
444 | 451 | | |
445 | 452 | | |
| |||
Lines changed: 44 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
0 commit comments