Skip to content

Commit

Permalink
Fix error handling and allow UUID or Int IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
TristenHarr committed Mar 22, 2024
1 parent a648851 commit 2e2de63
Show file tree
Hide file tree
Showing 10 changed files with 350 additions and 300 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ This changelog documents changes between release tags.
## [Unreleased]
Upcoming changes for the next versioned release.

## [0.1.6] - 2024-03-22
* Fix error handling
* Allow String (UUID) OR Integer IDs by introspecting the ID type.

## [0.1.5] - 2024-03-13
* Fix connector-metadata.yaml

Expand Down
4 changes: 2 additions & 2 deletions connector-definition/connector-metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
packagingDefinition:
type: PrebuiltDockerImage
dockerImage: ghcr.io/hasura/ndc-qdrant:v0.1.5
dockerImage: ghcr.io/hasura/ndc-qdrant:v0.1.6
supportedEnvironmentVariables:
- name: QDRANT_URL
description: The url for the Qdrant database
- name: QDRANT_API_KEY
description: The Qdrant API Key
commands:
update: docker run --rm -e QDRANT_URL="$QDRANT_URL" -e QDRANT_API_KEY="$QDRANT_API_KEY" -v "$HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH":/etc/connector ghcr.io/hasura/ndc-qdrant:v0.1.5 update
update: docker run --rm -e QDRANT_URL="$QDRANT_URL" -e QDRANT_API_KEY="$QDRANT_API_KEY" -v "$HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH":/etc/connector ghcr.io/hasura/ndc-qdrant:v0.1.6 update
dockerComposeWatch:
- path: ./
target: /etc/connector
Expand Down
53 changes: 51 additions & 2 deletions generate-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,72 @@ async function main() {
with_payload: true,
});
let fieldDict = {};
let baseFields = {};
let insertFields = {};
if (records.length > 0) {
console.log(records);
const recordPayload = records[0].payload;
fieldDict = insertion(cn, recordPayload!, objectTypes);
if (typeof records[0].id === "number"){
baseFields = {
id: {
description: null,
type: {
type: "named",
name: "Int",
},
},
...BASE_FIELDS
};
insertFields = {
id: {
description: null,
type: {
type: "named",
name: "Int",
},
},
...INSERT_FIELDS
};
} else {
baseFields = {
id: {
description: null,
type: {
type: "named",
name: "String",
},
},
...BASE_FIELDS
};
insertFields = {
id: {
description: null,
type: {
type: "named",
name: "String",
},
},
...INSERT_FIELDS
};
}
}
console.log(fieldDict);

objectTypes[cn] = {
description: null,
fields: {
...fieldDict,
...BASE_FIELDS,
...baseFields,
},
};

// Need to handle that here as well for insert fields.
objectTypes[`${cn}_InsertType`] = {
description: null,
fields: {
...fieldDict,
...INSERT_FIELDS
...insertFields
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ndc-qdrant",
"version": "0.1.5",
"version": "0.1.6",
"main": "index.js",
"scripts": {},
"dependencies": {
Expand Down
14 changes: 0 additions & 14 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,6 @@ export const SCALAR_TYPES: { [key: string]: ScalarType } = {
};

export const INSERT_FIELDS: Record<string, ObjectField> = {
id: {
description: null,
type: {
type: "named",
name: ID_FIELD_TYPE,
},
},
vector: {
description: null,
type: {
Expand All @@ -145,13 +138,6 @@ export const INSERT_FIELDS: Record<string, ObjectField> = {
};

export const BASE_FIELDS: Record<string, ObjectField> = {
id: {
description: null,
type: {
type: "named",
name: ID_FIELD_TYPE,
},
},
score: {
description: null,
type: {
Expand Down
Loading

0 comments on commit 2e2de63

Please sign in to comment.