Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/flat-chairs-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@team-plain/typescript-sdk': patch
---

Added `replyToThread` support. This lets you quickly reply to any thread when, for example, building an autoresponder.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ Every mutation error will contain:
- **fields**: an array containing all the fields that errored. Each field:
- **field**: the name of the input field the error is for
- **message**: an English technical description of the error. This error is usually meant to be read by a developer and not an end user.
type: one of `VALIDATION`, `REQUIRED`, `NOT_FOUND`. See [MutationFieldErrorType](https://docs.plain.com/core-api/reference/enums/mutation-field-error-type) for a description of each value.
type: one of `VALIDATION`, `REQUIRED`, `NOT_FOUND`. See [Error codes
](https://www.plain.com/docs/graphql/error-codes) in our docs for a description of each value.

### BadRequestError

Expand Down
12 changes: 12 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
RemoveCustomerFromCustomerGroupsDocument,
RemoveLabelsDocument,
ReplyToEmailDocument,
ReplyToThreadDocument,
SendNewEmailDocument,
SnoozeThreadDocument,
ThreadDocument,
Expand Down Expand Up @@ -285,6 +286,17 @@ export class PlainClient {
});
}

async replyToThread(input: VariablesOf<typeof ReplyToThreadDocument>['input']): SDKResult<null> {
const res = await request(this.#ctx, {
query: ReplyToThreadDocument,
variables: {
input,
},
});

return unwrapData(res, () => null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there no return?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, just error or nothing

}

async createAttachmentUploadUrl(
input: VariablesOf<typeof CreateAttachmentUploadUrlDocument>['input']
): SDKResult<AttachmentUploadUrlPartsFragment> {
Expand Down
7 changes: 7 additions & 0 deletions src/graphql/mutations/replyToThread.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mutation replyToThread($input: ReplyToThreadInput!) {
replyToThread(input: $input) {
error {
...MutationErrorParts
}
}
}
Loading