Commit 7d4e27e
Add Support for Vector Data Type in SQL for GraphQL (#3714)
## Why make this change?
- Solves issue #3682
## What is this change?
- In order to allow graphql to read array types that are not `[string]`
we moved the section that parses the scalar values to types hot
chocolate can use in order output them to the user. This new
`CoerceJsonLeafValueToRuntimeType` method is then used in a loop to
allow support for arrays inside the `ExecutionHelper.cs` file.
- In multiple places throughout the code, DAB looks at the SyntaxKind of
the values it is working with in order to know if the value can be
directly used or if it has a relationship with another entity. In order
to allow graphql to write to the data base, we now add a new function
`TryGetUnderlyingFieldKind` in `ISqlMetadataProvider.cs` that checks if
the value is a list and it comes from a row that has the `IsArrayType`.
If that condition is met, then it means the list value we have should be
processed as a regular ScalarType and not as a List/Object that is a
relationship to a different entity. This method is used in the following
files: `MultipleMutationInputValidator.cs`,
`MultipleCreateOrderHelper.cs`, `SqlMutationEnginge.cs`.
- Lastly, as part to allow graphql to write to the data base, we add a
new `GetStringifiedValue` function that checks if the value that we are
going to parse to the data base is a list or a regular value and
transforms it into a string accordingly. Since we set all values as
strings, this is something that cannot be directly done with a list as
the `.ToString()` function will return a useless value. This value is
then parsed before being used as a parameter in the data base query.
## How was this tested?
- [x] Integration Tests
- [ ] Unit Tests
Added tests that query (read) from the data base as well as mutation
(change) to the data base such as `create`, `update`, and `delete`.
## Sample Request(s)
Query
```
query {
dbo_normalvectors {
items {
Embedding
ProductID
}
}
}
```
<img width="407" height="368" alt="image"
src="https://github.com/user-attachments/assets/6e49c2c7-10e6-41af-abe9-aae10bc31604"
/>
Create
```
mutation {
createdbo_normalvector(
item: { ProductID: 10000, Embedding: [125, 1.22222, 0.75] }
) {
ProductID
Embedding
}
}
```
<img width="434" height="358" alt="image"
src="https://github.com/user-attachments/assets/613a9c2a-c95c-49bd-bf85-ede9e74030d9"
/>
Update
```
mutation {
updatedbo_normalvector(
ProductID: 10000,
item: { Embedding: [0.532, 200, 100.152] }
) {
ProductID
Embedding
}
}
```
<img width="461" height="322" alt="image"
src="https://github.com/user-attachments/assets/a6514f4d-6f27-41d5-812f-8e4825582a7f"
/>
Delete
```
mutation {
deletedbo_normalvector(
ProductID: 10000
) {
ProductID
Embedding
}
}
```
<img width="411" height="335" alt="image"
src="https://github.com/user-attachments/assets/0fe839f8-2732-481e-9d26-0fa74cd972b0"
/>
---------
Co-authored-by: souvikghosh04 <souvikofficial04@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>1 parent 90ccf42 commit 7d4e27e
18 files changed
Lines changed: 909 additions & 80 deletions
File tree
- config-generators
- src
- Core
- Resolvers
- Sql Query Structures
- Services
- MetadataProviders
- Service.Tests
- Snapshots
- SqlTests
- GraphQLQueryTests
- GraphQLSupportedTypesTests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
388 | | - | |
| 388 | + | |
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
724 | 724 | | |
725 | 725 | | |
726 | 726 | | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
727 | 744 | | |
728 | 745 | | |
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
114 | 115 | | |
115 | | - | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
186 | 187 | | |
187 | 188 | | |
188 | 189 | | |
189 | 190 | | |
190 | | - | |
| 191 | + | |
191 | 192 | | |
192 | 193 | | |
193 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| 193 | + | |
193 | 194 | | |
194 | 195 | | |
195 | 196 | | |
| |||
1066 | 1067 | | |
1067 | 1068 | | |
1068 | 1069 | | |
| 1070 | + | |
1069 | 1071 | | |
1070 | 1072 | | |
1071 | 1073 | | |
1072 | 1074 | | |
1073 | 1075 | | |
1074 | 1076 | | |
1075 | 1077 | | |
1076 | | - | |
| 1078 | + | |
1077 | 1079 | | |
1078 | 1080 | | |
1079 | 1081 | | |
| |||
1743 | 1745 | | |
1744 | 1746 | | |
1745 | 1747 | | |
1746 | | - | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
1747 | 1752 | | |
1748 | 1753 | | |
1749 | 1754 | | |
1750 | 1755 | | |
1751 | 1756 | | |
1752 | 1757 | | |
1753 | | - | |
| 1758 | + | |
1754 | 1759 | | |
1755 | 1760 | | |
1756 | 1761 | | |
| |||
1798 | 1803 | | |
1799 | 1804 | | |
1800 | 1805 | | |
1801 | | - | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
1802 | 1810 | | |
1803 | 1811 | | |
1804 | 1812 | | |
| |||
1820 | 1828 | | |
1821 | 1829 | | |
1822 | 1830 | | |
1823 | | - | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
1824 | 1835 | | |
1825 | 1836 | | |
1826 | 1837 | | |
| |||
1847 | 1858 | | |
1848 | 1859 | | |
1849 | 1860 | | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
1850 | 1871 | | |
1851 | 1872 | | |
1852 | 1873 | | |
1853 | 1874 | | |
1854 | 1875 | | |
1855 | | - | |
| 1876 | + | |
1856 | 1877 | | |
1857 | 1878 | | |
1858 | 1879 | | |
1859 | 1880 | | |
1860 | 1881 | | |
1861 | 1882 | | |
1862 | | - | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
1863 | 1887 | | |
1864 | 1888 | | |
1865 | 1889 | | |
1866 | 1890 | | |
1867 | 1891 | | |
1868 | 1892 | | |
1869 | | - | |
| 1893 | + | |
1870 | 1894 | | |
1871 | 1895 | | |
1872 | 1896 | | |
1873 | 1897 | | |
1874 | 1898 | | |
1875 | 1899 | | |
1876 | | - | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
1877 | 1904 | | |
1878 | 1905 | | |
1879 | 1906 | | |
| |||
2351 | 2378 | | |
2352 | 2379 | | |
2353 | 2380 | | |
2354 | | - | |
| 2381 | + | |
2355 | 2382 | | |
2356 | 2383 | | |
2357 | 2384 | | |
| |||
0 commit comments