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

Throw custom error if project could not be found #137

Closed
1 of 2 tasks
gr2m opened this issue Oct 5, 2023 · 1 comment · Fixed by #138
Closed
1 of 2 tasks

Throw custom error if project could not be found #137

gr2m opened this issue Oct 5, 2023 · 1 comment · Fixed by #138
Assignees

Comments

@gr2m
Copy link
Owner

gr2m commented Oct 5, 2023

Please avoid duplicates

What’s missing?

A custom error (see the existing ones) that is thrown in case a project cannot be found based on the provided owner and number.

Why?

The current behavior is to throw a GraphqlResponseError like this

GraphqlResponseError {
  data: {
    userOrOrganization: {
      projectV2: null,
    },
  },
  errors: [
    {
      locations: [
        {
          column: 9,
          line: 5,
        },
      ],
      message: 'Could not resolve to a ProjectV2 with the number 99999.',
      path: [
        'userOrOrganization',
        'projectV2',
      ],
      type: 'NOT_FOUND',
    },
  ],
  headers: {
    'access-control-allow-origin': '*',
    'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
    connection: 'close',
    'content-encoding': 'gzip',
    'content-security-policy': 'default-src \'none\'',
    'content-type': 'application/json; charset=utf-8',
    date: 'Sat, 20 May 2023 00:15:13 GMT',
    'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
    server: 'GitHub.com',
    'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
    'transfer-encoding': 'chunked',
    vary: 'Accept-Encoding, Accept, X-Requested-With',
    'x-content-type-options': 'nosniff',
    'x-frame-options': 'deny',
    'x-github-media-type': 'github.v3; format=json',
    'x-github-request-id': 'E53B:4AD2:8F6A462:944B6F1:64681111',
    'x-ratelimit-limit': '5000',
    'x-ratelimit-remaining': '4989',
    'x-ratelimit-reset': '1684545298',
    'x-ratelimit-resource': 'graphql',
    'x-ratelimit-used': '11',
    'x-xss-protection': '0',
  },
  request: {
    query: `␊
      query getProjectCoreData($owner: String!, $number: Int!) {␊
        userOrOrganization: repositoryOwner(login: $owner) {␊
          ... on ProjectV2Owner {␊
            projectV2(number: $number) {␊
              ␊
      id␊
      title␊
      url␊
      databaseId␊
      fields(first: 50) {␊
        nodes {␊
          ... on ProjectV2FieldCommon {␊
            id␊
            dataType␊
            name␊
          }␊
          ... on ProjectV2SingleSelectField {␊
            options {␊
              id␊
              name␊
            }␊
          }␊
          ... on ProjectV2IterationField {␊
            configuration {␊
              iterations {␊
                title␊
                duration␊
                startDate␊
              }␊
              completedIterations {␊
                title␊
                duration␊
                startDate␊
              }␊
              duration␊
              startDay␊
            }␊
          }␊
        }␊
      }␊
    ␊
            }␊
          }␊
        }␊
      }␊
    `,
    variables: {
      number: 99999,
      owner: 'github-project-fixtures',
    },
  },
  response: {
    data: {
      userOrOrganization: {
        projectV2: null,
      },
    },
    errors: [
      {
        locations: [
          {
            column: 9,
            line: 5,
          },
        ],
        message: 'Could not resolve to a ProjectV2 with the number 99999.',
        path: [
          'userOrOrganization',
          'projectV2',
        ],
        type: 'NOT_FOUND',
      },
    ],
  },
  message: `Request failed due to following response errors:␊
    - Could not resolve to a ProjectV2 with the number 99999.`,
}

Alternatives you tried

It's easy enough to look for the NOT_FOUND type in the GraphqlResponseError, but it's not very elegant.

Would you be interested in contributing the feature?

  • yes
@gr2m gr2m added the feature label Oct 5, 2023
@gr2m gr2m self-assigned this Oct 5, 2023
@gr2m gr2m closed this as completed in #138 Oct 5, 2023
gr2m added a commit that referenced this issue Oct 5, 2023
@github-actions
Copy link

github-actions bot commented Oct 5, 2023

🎉 This issue has been resolved in version 5.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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