Skip to content
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

Add support for CustomerNeed entity (Create, Trigger) #88

Merged

Conversation

guillaumelachaud
Copy link
Contributor

Adding support for CustomerNeed entity (Create, Trigger).

Copy link

linear bot commented Feb 5, 2025

Comment on lines +95 to +126
required: false,
label: "Customer ID",
helpText: "The ID of the customer to create the need for",
key: "customerId",
},
{
required: false,
label: "External Customer ID",
helpText: "The external ID of the customer the need belongs to",
key: "customerExternalId",
},
{
required: false,
label: "Issue ID",
helpText: "The ID of the issue this need is for",
key: "issueId",
type: "text",
},
{
required: false,
label: "Attachment ID",
helpText: "The ID of the attachment this need is associated with",
key: "attachmentId",
type: "text",
},
{
required: false,
label: "Attachment URL",
helpText: "Optional URL for the attachment associated with the customer need",
key: "attachmentUrl",
type: "text",
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

customerId and customerExternalId, as well as attachmentId and attachmentUrl are mutually exclusive. This is enforced at the GraphQL level but didn't see any good way to specify field constraints in the docs unless we want to go down the road of having dynamic fields. Not sure if it's worth the added complexity 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

You could throw an error before hitting our API in createCustomerNeedRequest if both fields are set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's probably the best option. I added some checks in createCustomerNeedRequest:

Before After
CleanShot 2025-02-06 at 09 40 12@2x CleanShot 2025-02-06 at 09 42 03@2x

Ideally, we would improve on the error parsing in order to relay all GraphQL validation errors. I will follow-up on that as we might want to make this error handling a bit more generic in order to benefit other Zapier creates.

Error payload
{
  "errors": [
    {
      "message": "Argument Validation Error",
      "path": [
        "customerNeedCreate"
      ],
      "locations": [
        {
          "line": 1,
          "column": 80
        }
      ],
      "extensions": {
        "code": "BAD_USER_INPUT",
        "validationErrors": [
          {
            "target": {
              "customerId": "5ae1a484-af7e-48aa-b32e-3d327ec599eb",
              "issueId": "28bf8fe5-5aac-4a1d-9fd0-057a1e9d6fdd",
              "attachmentId": "12",
              "body": "Content of the request",
              "attachmentUrl": "https://"
            },
            "value": "12",
            "property": "attachmentId",
            "children": [],
            "constraints": {
              "isUuid": "attachmentId must be a UUID"
            }
          },
          {
            "target": {
              "customerId": "5ae1a484-af7e-48aa-b32e-3d327ec599eb",
              "issueId": "28bf8fe5-5aac-4a1d-9fd0-057a1e9d6fdd",
              "attachmentId": "12",
              "body": "Content of the request",
              "attachmentUrl": "https://"
            },
            "value": "https://",
            "property": "attachmentUrl",
            "children": [],
            "constraints": {
              "customValidation": "attachmentUrl is not a valid URL"
            }
          }
        ],
        "type": "graphql error",
        "userError": true,
        "exception": {
          "message": "Argument Validation Error",
          "locations": [
            {
              "line": 1,
              "column": 80
            }
          ],
          "path": [
            "customerNeedCreate"
          ],
          "extensions": {
            "code": "BAD_USER_INPUT",
            "validationErrors": [
              {
                "target": {
                  "customerId": "5ae1a484-af7e-48aa-b32e-3d327ec599eb",
                  "issueId": "28bf8fe5-5aac-4a1d-9fd0-057a1e9d6fdd",
                  "attachmentId": "12",
                  "body": "Content of the request",
                  "attachmentUrl": "https://"
                },
                "value": "12",
                "property": "attachmentId",
                "children": [],
                "constraints": {
                  "isUuid": "attachmentId must be a UUID"
                }
              },
              {
                "target": {
                  "customerId": "5ae1a484-af7e-48aa-b32e-3d327ec599eb",
                  "issueId": "28bf8fe5-5aac-4a1d-9fd0-057a1e9d6fdd",
                  "attachmentId": "12",
                  "body": "Content of the request",
                  "attachmentUrl": "https://"
                },
                "value": "https://",
                "property": "attachmentUrl",
                "children": [],
                "constraints": {
                  "customValidation": "attachmentUrl is not a valid URL"
                }
              }
            ]
          }
        }
      }
    }
  ],
  "data": null

@guillaumelachaud guillaumelachaud merged commit b8b04c6 into master Feb 7, 2025
1 check passed
@Sophie1142
Copy link

Hello, is CustomerNeed the same as Linear's Customer Request?

Copy link
Contributor Author

Yes. You can find more documentation about the Customers data models here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants