Module: PlanMyStuff::GraphQL::Queries
- Defined in:
- lib/plan_my_stuff/graphql/queries.rb
Overview
Consolidated GitHub GraphQL queries and mutations used by the gem. Strings are static (no runtime parameterization) so they live as frozen String constants rather than methods.
Callers pass the constant straight to PlanMyStuff.client.graphql:
PlanMyStuff.client.graphql(
PlanMyStuff::GraphQL::Queries::DELETE_PROJECT_ITEM,
variables: { projectId: ..., itemId: ... },
)
Constant Summary collapse
- ORG_ID =
— Organization / project lookup ———————————
<<~GRAPHQL query($org: String!) { organization(login: $org) { id } } GRAPHQL
- PROJECT_ID =
<<~GRAPHQL query($org: String!, $number: Int!) { organization(login: $org) { projectV2(number: $number) { id } } } GRAPHQL
- USER_NODE_ID =
<<~GRAPHQL query($login: String!) { user(login: $login) { id } } GRAPHQL
- LIST_PROJECTS =
— Project list / find ——————————————-
<<~GRAPHQL query($org: String!) { organization(login: $org) { projectsV2(first: 100) { nodes { id number title shortDescription readme url closed updatedAt } } } } GRAPHQL
- FIND_PROJECT =
<<~GRAPHQL.freeze query($org: String!, $number: Int!, $cursor: String) { organization(login: $org) { projectV2(number: $number) { id number title shortDescription readme url closed updatedAt fields(first: 50) { nodes { ... on ProjectV2SingleSelectField { id name options { id name } } ... on ProjectV2Field { id name } ... on ProjectV2IterationField { id name } } } items(first: #{PlanMyStuff::BaseProject::ITEMS_PER_PAGE}, after: $cursor) { pageInfo { hasNextPage endCursor } nodes { id type updatedAt content { ... on Issue { id title number url state repository { nameWithOwner } assignees(first: 10) { nodes { login } } } ... on PullRequest { id title number url state repository { nameWithOwner } assignees(first: 10) { nodes { login } } } ... on DraftIssue { id title body assignees(first: 10) { nodes { login } } } } fieldValues(first: 20) { nodes { ... on ProjectV2ItemFieldSingleSelectValue { name field { ... on ProjectV2SingleSelectField { name } } } ... on ProjectV2ItemFieldTextValue { text field { ... on ProjectV2Field { name } } } ... on ProjectV2ItemFieldDateValue { date field { ... on ProjectV2Field { name } } } ... on ProjectV2ItemFieldUserValue { users(first: 10) { nodes { login } } field { ... on ProjectV2Field { name } } } } } } } } } } GRAPHQL
- CREATE_PROJECT =
— Project mutations ———————————————
<<~GRAPHQL mutation($input: CreateProjectV2Input!) { createProjectV2(input: $input) { projectV2 { id number } } } GRAPHQL
- COPY_PROJECT_V2 =
<<~GRAPHQL mutation($input: CopyProjectV2Input!) { copyProjectV2(input: $input) { projectV2 { id number } } } GRAPHQL
- UPDATE_PROJECT =
<<~GRAPHQL mutation($input: UpdateProjectV2Input!) { updateProjectV2(input: $input) { projectV2 { id number } } } GRAPHQL
- ADD_ITEM =
— Project item mutations —————————————-
<<~GRAPHQL mutation($projectId: ID!, $contentId: ID!) { addProjectV2ItemById(input: { projectId: $projectId, contentId: $contentId }) { item { id } } } GRAPHQL
- ADD_DRAFT_ITEM =
<<~GRAPHQL mutation($projectId: ID!, $title: String!, $body: String) { addProjectV2DraftIssue(input: { projectId: $projectId, title: $title, body: $body }) { projectItem { id content { ... on DraftIssue { id body } } } } } GRAPHQL
- UPDATE_SINGLE_SELECT_FIELD =
<<~GRAPHQL mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) { updateProjectV2ItemFieldValue(input: { projectId: $projectId, itemId: $itemId, fieldId: $fieldId, value: { singleSelectOptionId: $optionId } }) { projectV2Item { id } } } GRAPHQL
- UPDATE_TEXT_FIELD =
<<~GRAPHQL mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: String!) { updateProjectV2ItemFieldValue(input: { projectId: $projectId, itemId: $itemId, fieldId: $fieldId, value: { text: $value } }) { projectV2Item { id } } } GRAPHQL
- CREATE_PROJECT_V2_FIELD =
<<~GRAPHQL mutation($input: CreateProjectV2FieldInput!) { createProjectV2Field(input: $input) { projectV2Field { ... on ProjectV2Field { id name } ... on ProjectV2SingleSelectField { id name } } } } GRAPHQL
- DELETE_PROJECT_V2_FIELD =
<<~GRAPHQL mutation($input: DeleteProjectV2FieldInput!) { deleteProjectV2Field(input: $input) { projectV2Field { ... on ProjectV2Field { id } ... on ProjectV2SingleSelectField { id } } } } GRAPHQL
- UPDATE_DATE_FIELD =
<<~GRAPHQL mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $date: Date!) { updateProjectV2ItemFieldValue(input: { projectId: $projectId, itemId: $itemId, fieldId: $fieldId, value: { date: $date } }) { projectV2Item { id } } } GRAPHQL
- DELETE_PROJECT_ITEM =
<<~GRAPHQL mutation($projectId: ID!, $itemId: ID!) { deleteProjectV2Item(input: { projectId: $projectId, itemId: $itemId }) { deletedItemId } } GRAPHQL
- ASSIGN_DRAFT =
<<~GRAPHQL mutation($draftIssueId: ID!, $assigneeIds: [ID!]) { updateProjectV2DraftIssue(input: { draftIssueId: $draftIssueId, assigneeIds: $assigneeIds }) { draftIssue { id } } } GRAPHQL
- FETCH_DUPLICATE_OF =
— Issue relationships ——————————————-
Sub-issues (parent / sub_tickets) and issue dependencies (blocking / blocked_by) are both handled via REST in
Issue:-
/repos/{owner}/{repo}/issues/{number}/parent
-
/repos/{owner}/{repo}/issues/{number}/sub_issues
-
/repos/{owner}/{repo}/issues/{number}/sub_issue (DELETE)
-
/repos/{owner}/{repo}/issues/{number}/dependencies/{side}
Only
duplicate_ofstill uses GraphQL. -
<<~GRAPHQL query($owner: String!, $repo: String!, $number: Int!) { repository(owner: $owner, name: $repo) { issue(number: $number) { stateReason duplicateOf { number repository { nameWithOwner } } } } } GRAPHQL
- CLOSE_AS_DUPLICATE =
<<~GRAPHQL mutation($issueId: ID!, $duplicateIssueId: ID!) { closeIssue(input: { issueId: $issueId, stateReason: DUPLICATE, duplicateIssueId: $duplicateIssueId }) { issue { number stateReason } } } GRAPHQL
- LIST_ISSUE_PROJECT_ITEMS =
— Archive support ———————————————–
<<~GRAPHQL query($owner: String!, $repo: String!, $number: Int!, $cursor: String) { repository(owner: $owner, name: $repo) { issue(number: $number) { projectItems(first: 50, after: $cursor) { pageInfo { hasNextPage endCursor } nodes { id project { id number } } } } } } GRAPHQL
- LIST_ORG_ISSUE_FIELDS =
— Issue Fields (org-level public preview) ———————–
<<~GRAPHQL query($org: String!) { organization(login: $org) { issueFields(first: 50) { nodes { __typename ... on IssueFieldText { id name description } ... on IssueFieldNumber { id name description } ... on IssueFieldDate { id name description } ... on IssueFieldSingleSelect { id name description options { id name description color } } } } } } GRAPHQL
- READ_ISSUE_FIELD_VALUES =
<<~GRAPHQL query($owner: String!, $name: String!, $number: Int!) { repository(owner: $owner, name: $name) { issue(number: $number) { issueFieldValues(first: 50) { nodes { __typename ... on IssueFieldTextValue { value field { ... on IssueFieldText { id name } } } ... on IssueFieldNumberValue { value field { ... on IssueFieldNumber { id name } } } ... on IssueFieldDateValue { value field { ... on IssueFieldDate { id name } } } ... on IssueFieldSingleSelectValue { name optionId field { ... on IssueFieldSingleSelect { id name } } } } } } } } GRAPHQL
- SET_ISSUE_FIELD_VALUES =
<<~GRAPHQL mutation($issueId: ID!, $issueFields: [IssueFieldCreateOrUpdateInput!]!) { setIssueFieldValue(input: { issueId: $issueId, issueFields: $issueFields }) { issue { number } } } GRAPHQL