Skip to content

Commit

Permalink
DEVPROD-5460: Remove deprecated arguments from GraphQL API (evergreen…
Browse files Browse the repository at this point in the history
  • Loading branch information
minnakt authored and malikchaya2 committed Apr 10, 2024
1 parent 6884245 commit 65dd993
Show file tree
Hide file tree
Showing 98 changed files with 175 additions and 279 deletions.
155 changes: 53 additions & 102 deletions graphql/generated.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion graphql/mutation_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ func (r *mutationResolver) RestartTask(ctx context.Context, taskID string, faile
}

// ScheduleTasks is the resolver for the scheduleTasks field.
func (r *mutationResolver) ScheduleTasks(ctx context.Context, taskIds []string, versionID *string) ([]*restModel.APITask, error) {
func (r *mutationResolver) ScheduleTasks(ctx context.Context, taskIds []string, versionID string) ([]*restModel.APITask, error) {
scheduledTasks := []*restModel.APITask{}
scheduled, err := setManyTasksScheduled(ctx, r.sc.GetURL(), true, taskIds...)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions graphql/project_settings_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func (r *projectSettingsResolver) Vars(ctx context.Context, obj *restModel.APIPr
}

// ProjectID is the resolver for the projectId field.
func (r *projectSettingsInputResolver) ProjectID(ctx context.Context, obj *restModel.APIProjectSettings, data *string) error {
obj.Id = data
func (r *projectSettingsInputResolver) ProjectID(ctx context.Context, obj *restModel.APIProjectSettings, data string) error {
obj.Id = utility.ToStringPtr(data)
return nil
}

Expand Down
48 changes: 18 additions & 30 deletions graphql/query_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/evergreen-ci/evergreen/rest/data"
restModel "github.com/evergreen-ci/evergreen/rest/model"
"github.com/evergreen-ci/evergreen/thirdparty"
"github.com/evergreen-ci/evergreen/util"
"github.com/evergreen-ci/plank"
"github.com/evergreen-ci/utility"
"github.com/mongodb/anser/bsonutil"
Expand Down Expand Up @@ -374,16 +373,14 @@ func (r *queryResolver) Pod(ctx context.Context, podID string) (*restModel.APIPo
}

// Patch is the resolver for the patch field.
func (r *queryResolver) Patch(ctx context.Context, id *string, patchID *string) (*restModel.APIPatch, error) {
// TODO: Remove this temporary workaround.
patchId := util.CoalesceString(utility.FromStringPtr(id), utility.FromStringPtr(patchID))
patch, err := data.FindPatchById(patchId)
func (r *queryResolver) Patch(ctx context.Context, patchID string) (*restModel.APIPatch, error) {
patch, err := data.FindPatchById(patchID)
if err != nil {
return nil, InternalServerError.Send(ctx, err.Error())
}

if evergreen.IsFinishedVersionStatus(*patch.Status) {
statuses, err := task.GetTaskStatusesByVersion(ctx, patchId, false)
statuses, err := task.GetTaskStatusesByVersion(ctx, patchID, false)
if err != nil {
return nil, InternalServerError.Send(ctx, fmt.Sprintf("fetching task statuses for patch: %s", err.Error()))
}
Expand Down Expand Up @@ -495,14 +492,12 @@ func (r *queryResolver) ProjectSettings(ctx context.Context, identifier string)
}

// RepoEvents is the resolver for the repoEvents field.
func (r *queryResolver) RepoEvents(ctx context.Context, repoID *string, id *string, limit *int, before *time.Time) (*ProjectEvents, error) {
// TODO: Remove this temporary workaround.
repoId := util.CoalesceString(utility.FromStringPtr(id), utility.FromStringPtr(repoID))
func (r *queryResolver) RepoEvents(ctx context.Context, repoID string, limit *int, before *time.Time) (*ProjectEvents, error) {
timestamp := time.Now()
if before != nil {
timestamp = *before
}
events, err := data.GetEventsById(repoId, timestamp, utility.FromIntPtr(limit))
events, err := data.GetEventsById(repoID, timestamp, utility.FromIntPtr(limit))
res := &ProjectEvents{
EventLogEntries: getPointerEventList(events),
Count: len(events),
Expand All @@ -511,10 +506,8 @@ func (r *queryResolver) RepoEvents(ctx context.Context, repoID *string, id *stri
}

// RepoSettings is the resolver for the repoSettings field.
func (r *queryResolver) RepoSettings(ctx context.Context, repoID *string, id *string) (*restModel.APIProjectSettings, error) {
// TODO: Remove this temporary workaround.
repoId := util.CoalesceString(utility.FromStringPtr(id), utility.FromStringPtr(repoID))
repoRef, err := model.FindOneRepoRef(repoId)
func (r *queryResolver) RepoSettings(ctx context.Context, repoID string) (*restModel.APIProjectSettings, error) {
repoRef, err := model.FindOneRepoRef(repoID)
if err != nil {
return nil, InternalServerError.Send(ctx, fmt.Sprintf("error looking in repo collection: %s", err.Error()))
}
Expand Down Expand Up @@ -976,40 +969,35 @@ func (r *queryResolver) TaskNamesForBuildVariant(ctx context.Context, projectIde
}

// HasVersion is the resolver for the hasVersion field.
func (r *queryResolver) HasVersion(ctx context.Context, id *string, patchID *string) (bool, error) {
// TODO: Remove this temporary workaround.
patchId := util.CoalesceString(utility.FromStringPtr(id), utility.FromStringPtr(patchID))

v, err := model.VersionFindOne(model.VersionById(patchId))
func (r *queryResolver) HasVersion(ctx context.Context, patchID string) (bool, error) {
v, err := model.VersionFindOne(model.VersionById(patchID))
if err != nil {
return false, InternalServerError.Send(ctx, fmt.Sprintf("finding version '%s': %s", patchId, err.Error()))
return false, InternalServerError.Send(ctx, fmt.Sprintf("finding version '%s': %s", patchID, err.Error()))
}
if v != nil {
return true, nil
}

if patch.IsValidId(patchId) {
p, err := patch.FindOneId(patchId)
if patch.IsValidId(patchID) {
p, err := patch.FindOneId(patchID)
if err != nil {
return false, InternalServerError.Send(ctx, fmt.Sprintf("finding patch '%s': %s", patchId, err.Error()))
return false, InternalServerError.Send(ctx, fmt.Sprintf("finding patch '%s': %s", patchID, err.Error()))
}
if p != nil {
return false, nil
}
}
return false, ResourceNotFound.Send(ctx, fmt.Sprintf("Unable to find patch or version %s", patchId))
return false, ResourceNotFound.Send(ctx, fmt.Sprintf("Unable to find patch or version %s", patchID))
}

// Version is the resolver for the version field.
func (r *queryResolver) Version(ctx context.Context, id *string, versionID *string) (*restModel.APIVersion, error) {
// TODO: Remove this temporary workaround.
versionId := util.CoalesceString(utility.FromStringPtr(id), utility.FromStringPtr(versionID))
v, err := model.VersionFindOneId(versionId)
func (r *queryResolver) Version(ctx context.Context, versionID string) (*restModel.APIVersion, error) {
v, err := model.VersionFindOneId(versionID)
if err != nil {
return nil, InternalServerError.Send(ctx, fmt.Sprintf("finding version '%s': %s", versionId, err.Error()))
return nil, InternalServerError.Send(ctx, fmt.Sprintf("finding version '%s': %s", versionID, err.Error()))
}
if v == nil {
return nil, ResourceNotFound.Send(ctx, fmt.Sprintf("version '%s' not found", versionId))
return nil, ResourceNotFound.Send(ctx, fmt.Sprintf("version '%s' not found", versionID))
}
apiVersion := restModel.APIVersion{}
apiVersion.BuildFromService(*v)
Expand Down
4 changes: 2 additions & 2 deletions graphql/repo_settings_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func (r *repoSettingsResolver) Vars(ctx context.Context, obj *restModel.APIProje
}

// RepoID is the resolver for the repoId field.
func (r *repoSettingsInputResolver) RepoID(ctx context.Context, obj *restModel.APIProjectSettings, data *string) error {
obj.Id = data
func (r *repoSettingsInputResolver) RepoID(ctx context.Context, obj *restModel.APIProjectSettings, data string) error {
obj.Id = utility.ToStringPtr(data)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion graphql/schema/mutation.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type Mutation {
abortTask(taskId: String!): Task!
overrideTaskDependencies(taskId: String!): Task!
restartTask(taskId: String!, failedOnly: Boolean!): Task!
scheduleTasks(taskIds: [String!]!, versionId: String): [Task!]!
scheduleTasks(taskIds: [String!]!, versionId: String!): [Task!]!
setTaskPriority(taskId: String!, priority: Int!): Task!
unscheduleTask(taskId: String!): Task!

Expand Down
10 changes: 5 additions & 5 deletions graphql/schema/query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Query {
pod(podId: String!): Pod!

# patch
patch(id: String @deprecated(reason: "use patchId instead"), patchId: String): Patch!
patch(patchId: String!): Patch!

# project
githubProjectConflicts(projectId: String!): GithubProjectConflicts!
Expand All @@ -55,8 +55,8 @@ type Query {
@requireProjectAccess(access: VIEW)
): ProjectEvents!
projectSettings(identifier: String! @requireProjectAccess(access: VIEW)): ProjectSettings!
repoEvents(repoId: String @requireProjectAccess(access: VIEW), id: String @deprecated(reason: "use repoId instead"), limit: Int = 0, before: Time): ProjectEvents!
repoSettings(repoId: String @requireProjectAccess(access: VIEW), id: String @deprecated(reason: "use repoId instead")): RepoSettings!
repoEvents(repoId: String! @requireProjectAccess(access: VIEW), limit: Int = 0, before: Time): ProjectEvents!
repoSettings(repoId: String! @requireProjectAccess(access: VIEW)): RepoSettings!
viewableProjectRefs: [GroupedProjects]!

# spawn
Expand Down Expand Up @@ -89,6 +89,6 @@ type Query {
taskNamesForBuildVariant(projectIdentifier: String!, buildVariant: String!): [String!]

# version
hasVersion(id: String @deprecated(reason: "use patchId instead"), patchId: String): Boolean!
version(id: String @deprecated(reason: "use versionId instead"), versionId: String): Version!
hasVersion(patchId: String!): Boolean!
version(versionId: String!): Version!
}
2 changes: 1 addition & 1 deletion graphql/schema/types/project_settings.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ It contains information about project settings (e.g. Build Baron configurations,
update the settings for a given project.
"""
input ProjectSettingsInput {
projectId: String # TODO: Make this required.
projectId: String!
aliases: [ProjectAliasInput!]
githubWebhooksEnabled: Boolean
projectRef: ProjectInput
Expand Down
2 changes: 1 addition & 1 deletion graphql/schema/types/repo_settings.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ It contains information about repo settings (e.g. Build Baron configurations, su
update the settings for a given project.
"""
input RepoSettingsInput {
repoId: String # TODO: Make this required.
repoId: String!
aliases: [ProjectAliasInput!]
githubWebhooksEnabled: Boolean
projectRef: RepoRefInput ## use the repo ref here in order to have stronger types
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
mutation {
saveProjectSettingsForSection(
projectSettings: {
projectId: "second_project_id"
projectRef: {
id: "second_project_id",
id: "second_project_id"
identifier: "sandbox"
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mutation {
saveProjectSettingsForSection(
projectSettings: {
projectId: "sandbox_project_id"
projectRef: {
id: "sandbox_project_id"
commitQueue: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
mutation {
saveProjectSettingsForSection(
projectSettings: {
projectId: "sandbox_project_id"
projectRef: {
id: "sandbox_project_id",
identifier: "sandbox",
enabled: true,
id: "sandbox_project_id"
identifier: "sandbox"
enabled: true
remotePath: "my_path_is_new"
owner: "evergreen-ci"
repo: "commit-queue-sandbox"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mutation {
saveProjectSettingsForSection(
projectSettings: {
projectId: "sandbox_project_id"
projectRef: {
id: "sandbox_project_id"
banner: { theme: WARNING, text: "banner text!!" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mutation {
saveProjectSettingsForSection(
projectSettings: {
projectId: "sandbox_project_id"
projectRef: {
id: "sandbox_project_id"
patchTriggerAliases: []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mutation {
saveProjectSettingsForSection(
projectSettings: {
projectId: "sandbox_project_id"
projectRef: {
id: "sandbox_project_id"
patchTriggerAliases: []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
mutation {
saveProjectSettingsForSection(
projectSettings: {
projectId: "sandbox_project_id"
projectRef: {
id: "sandbox_project_id"
id: "sandbox_project_id"
}
vars: {
vars: {goodbye: "now"},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mutation {
saveProjectSettingsForSection(
projectSettings: {
projectId: "sandbox_project_id"
projectRef: {
id: "sandbox_project_id"
parsleyFilters: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mutation {
saveRepoSettingsForSection(
repoSettings: {
repoId: "repo_id"
projectRef: {
id: "repo_id"
commitQueue: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mutation {
saveRepoSettingsForSection(
repoSettings: {
repoId: "repo_id"
projectRef: {
id: "repo_id"
owner: "hello",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mutation {
saveRepoSettingsForSection(
repoSettings: {
repoId: "repo_id"
projectRef: {
id: "repo_id"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mutation {
scheduleTasks(taskIds: ["wuzzup"]) {
scheduleTasks(taskIds: ["wuzzup"], versionId: "version") {
status
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mutation {
scheduleTasks(taskIds: ["non-existent"]) {
scheduleTasks(taskIds: ["non-existent"], versionId: "version") {
status
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
patch(id: "5dd2e89cd1fe07048e43bb9c") {
patch(patchId: "5dd2e89cd1fe07048e43bb9c") {
baseTaskStatuses
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
patch(id: "5e4ff3abe3c3317e352062e4") {
patch(patchId: "5e4ff3abe3c3317e352062e4") {
id
versionFull {
baseVersion {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
patch(id: "5d7288d91f8c8a403bc34a7d") {
patch(patchId: "5d7288d91f8c8a403bc34a7d") {
id
versionFull {
baseVersion {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
patch(id: "9e4ff3abe3c3317e352062e4") {
patch(patchId: "9e4ff3abe3c3317e352062e4") {
builds {
id
buildVariant
Expand Down
2 changes: 1 addition & 1 deletion graphql/tests/patch/builds/queries/builds_exist.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
patch(id: "5e94c8213e8e8651bee37561") {
patch(patchId: "5e94c8213e8e8651bee37561") {
builds {
id
buildVariant
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
patch(id: "5e4ff3abe3c3317e352062e1") {
patch(patchId: "5e4ff3abe3c3317e352062e1") {
childPatchAliases {
alias
patchId
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
patch(id: "5e4ff3abe3c3317e352062e1") {
patch(patchId: "5e4ff3abe3c3317e352062e1") {
id
childPatches {
id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
patch(id: "5d7288d91f8c8a403bc34a7d") {
patch(patchId: "5d7288d91f8c8a403bc34a7d") {
id
childPatches {
id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
patch(id: "5c74085f32f41738270aeba8") {
patch(patchId: "5c74085f32f41738270aeba8") {
commitQueuePosition
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
patch(id: "64db7d48b237368d9eea0d10") {
patch(patchId: "64db7d48b237368d9eea0d10") {
commitQueuePosition
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
patch(id: "9e4ff3abe3c3317e352062e4") {
patch(patchId: "9e4ff3abe3c3317e352062e4") {
commitQueuePosition
}
}
2 changes: 1 addition & 1 deletion graphql/tests/patch/createTime/queries/create_time.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
patch(id: "5e94c8213e8e8651bee37561") {
patch(patchId: "5e94c8213e8e8651bee37561") {
createTime
}
}
Loading

0 comments on commit 65dd993

Please sign in to comment.