-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(api): [NAN-793] bulk metadata update api #2145
feat(api): [NAN-793] bulk metadata update api #2145
Conversation
…-bulk-metadata-update-api-planning
docs-v2/mint.json
Outdated
@@ -522,7 +522,9 @@ | |||
"reference/api/connection/get", | |||
"reference/api/connection/post", | |||
"reference/api/connection/set-metadata", | |||
"reference/api/connection/bulk-set-metadata", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need new endpoints for this? Can we just support both a single value and an array in the existing routes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That what I would have liked to do but we can't without deprecating this current method. This is because the connectionId
is passed as part of the URL:
curl --location --request PATCH 'http://localhost:3003/connection/to-override/metadata?provider_config_key=google-calendar' \
--header 'Content-Type: application/json' \
--data '{
"myMetadata": "bar"
}'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. In this case, I would aim to make this endpoint the new standard, and later deprecate the other one, so we keep a minimal number of endpoints.
In order to do so, I would remove bulk
from the endpoint and have something like:
PATCH https://api.nango.dev/connection/update-metadata
POST https://api.nango.dev/connection/set-metadata
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's logical. It is mirroring the endpoints to modify metadata for a single connection
// single connection
POST /connection/:connectionId/metadata
PATCH /connection/:connectionId/metadata
// multiple connection
POST /connection/metadata
PATCH /connection/metadata
…-bulk-metadata-update-api-planning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌🏻
It would have been great to use the new pattern of creating routes, just to have some payload validation and test but not blocking
The older metadata endpoints still exist but now exist in the documentation marked as legacy. One more pass is requested to the interface and implementation @bastienbeurier @TBonnin @bodinsamuel |
docs-v2/spec.yaml
Outdated
patch: | ||
description: Edit custom metadata for the connection or connections (only overrides specified properties, not the entire metadata). If updating multiple connections pass in an array of connection ids instead of a string. | ||
parameters: | ||
- name: provider_config_key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here about the query apram
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
…-bulk-metadata-update-api-planning
…-bulk-metadata-update-api-planning
Added with 81943a6 |
public async updateMetadata(connections: Connection[], metadata: Metadata): Promise<void> { | ||
for (const connection of connections) { | ||
const newMetadata = { ...connection.metadata, ...metadata }; | ||
await this.replaceMetadata([connection.id as number], newMetadata); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would have been nice to have all the queries as part of a transaction. Here we might potentially have some out of sync Metadata if one or more query fails somehow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with 25669dc
…-bulk-metadata-update-api-planning
Describe your changes
Update the set and update metadata endpoints to accept an array of connection ids. If any invalid connection is passed in at any point in the array the entire operation is bailed and no metadata is set.
Issue ticket number and link
NAN-793
Checklist before requesting a review (skip if just adding/editing APIs & templates)