You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7d4e27e
Browse filesBrowse the repository at this point in the historyBrowse files
authored
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>
0 commit comments