data-api-builder
data-api-builder copied to clipboard
"The 'kind' value 'MultiHash' specified in the partition key definition is invalid. Please choose 'Hash' partition type."
Hi there! I'm using DAB to query a CosmosDB NoSQL container with partition keys of:
id: ID
/TenantId: String
/EntityType: String
/EntityId: String
Example:
The items within this table have been assigned the model of "Location"
I am trying to create an item using the "createLocation" function generated by DAB, with a mutation such as the below:
mutation{
createLocation(item:{
TenantId: "1",
EntityType: "FromDAB",
EntityId: "1",
Address: "HelloGitHub"
}) {
TenantId
EntityType
EntityId
Address
}
}
However I get a 404 message with the error:
The 'kind' value 'MultiHash' specified in the partition key definition is invalid. Please choose 'Hash' partition type.
Please could you let me know how I can use the "createLocation" mutation correctly to create an item within my database?
Thanks!
Rich
@jacksorjacksor How are you passing the partition key? Can you provide a sample?
Hi @sajeetharan / @neeraj-sharma2592, thanks for getting back to me.
How are you passing the partition key?
At this point I don't believe that I am passing in the partition key. Where should I do that as part of DAB's usage?
Can you provide a sample?
I've included:
schema.gql[manually created]config.dab[created throughdab init]- sample item from Cosmos DB
Let me know if any other samples would be appropriate.
Rich
schema.gql
type Location @model{
id: ID
TenantId: String
EntityType: String
EntityId: String
Address: String
Buildings: [Building]
}
type Building{
id: ID
Name: String
Levels: [Level]
}
type Level{
id: ID
Name: String
}
dab-config.json
{
"$schema": "https://github.com/Azure/data-api-builder/releases/download/v0.8.50/dab.draft.schema.json",
"data-source": {
"database-type": "cosmosdb_nosql",
"connection-string": "AccountEndpoint=[REDACTED]",
"options": {
"database": "RichDb01",
"container": "MRP",
"schema": "schema.gql"
}
},
"runtime": {
"rest": {
"enabled": false,
"path": "/api"
},
"graphql": {
"enabled": true,
"path": "/graphql",
"allow-introspection": true
},
"host": {
"cors": {
"origins": [],
"allow-credentials": false
},
"authentication": {
"provider": "StaticWebApps"
},
"mode": "development"
}
},
"entities": {
"Location": {
"source": "MRP",
"permissions": [
{
"role": "anonymous",
"actions": ["*"]
}
]
}
}
}
Sample item from Cosmos DB
{
"id": "1-Location-1",
"TenantId": "1",
"EntityType": "Location",
"EntityId": "1",
"Address": "44 My Road, My Address, Postcode",
"Buildings": [
{
"id": "1-Location-1-Building-1",
"Name": "My First Building",
"Levels": [
{
"id": "1-Location-1-Building-1-Level-1",
"Name": "Level 1"
}
]
},
{
"id": "1-Location-1-Building-2",
"Name": "My Second Building",
"Levels": [
{
"id": "1-Location-1-Building-2-Level-1",
"Name": "Level 1"
}
]
}
],
// metadata (removed)
}
@jacksorjacksor Thanks a lot for providing the config and the sample. It's a limitation of DAB for Azure Cosmos DB as we currently use 3.20.0 which does not support hierarchical partitioning.
We are in the process of upgrading our SDK within DAB engine and will keep you posted.
Another question : were you able to perform query operation with Hierarchical Petitioning enabled?
@sajeetharan Hi there - huge apologies for the delay.
I'm able to run a basic ReadItemAsync() query on the Cosmos DB Emulator (on a container with a hierarchical partition key) through using the .NET SDK v3, but not through the Data Explorer.
Has there been any updates on whether DAB is supporting Hierarchical Partitioning?
@sajeetharan Hi there - huge apologies for the delay.
I'm able to run a basic ReadItemAsync() query on the Cosmos DB Emulator (on a container with a hierarchical partition key) through using the .NET SDK v3, but not through the Data Explorer.
Has there been any updates on whether DAB is supporting Hierarchical Partitioning?
Hi @jacksorjacksor, .Net SDK > 3.33.0 Supports Hierarchical Partitioning, as you mentioned that's the reason you see it working with emulator, DAB uses the .Net SDK version 3.20, we investigated supporting Hierarchical partitioning as a feature through DAB with Mutation and Queries, which requires a upgrading the SDK as well as design change. Our tentative ETA to support this is by April 2024. Let me know if you can wait till that.
@sajeetharan ok great, thanks for the confirmation!
@sajeetharan Is there any update on the support of Hierarchical Partitioning?
It's April 2025. We are using more and more containers with hierarchical keys and unless API Builder supports this we cannot use it. Any new update on it?