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

DEVPROD-5460: Update GraphQL API with more specific arguments #7682

Merged
merged 8 commits into from
Mar 29, 2024

Conversation

minnakt
Copy link
Contributor

@minnakt minnakt commented Mar 25, 2024

DEVPROD-5460

Description

We are updating the GraphQL API to be more explicit about parameters. For example, if the input is expected to be a version ID, the parameter should explicitly be called versionId rather than just id. We need these explicit parameters in order to support the new project permissions directive.

The old parameters will need to continue to be supported temporarily for backwards compatibility.

Note for the UI team

I think the guidelines for using objects for inputs/payloads are only for mutations. When I checked some famous GraphQL APIs (like GitHub and Shopify), they seemed to only use that pattern for mutations.

Testing

  • Existing GraphQL tests should pass
  • Added some new GraphQL tests that use the new parameters

@minnakt minnakt marked this pull request as ready for review March 25, 2024 18:57
@minnakt minnakt requested review from a team March 25, 2024 18:57
Copy link
Contributor

@sophstad sophstad left a comment

Choose a reason for hiding this comment

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

"famous GraphQL APIs" made me laugh

hasVersion(id: String!): Boolean!
version(id: String!): Version!
hasVersion(id: String @deprecated(reason: "use patchId instead"), patchId: String): Boolean!
version(id: String @deprecated(reason: "use versionId instead"), versionId: String): Version!
Copy link
Contributor

Choose a reason for hiding this comment

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

For clarification, will this change ever be safe to make in a backwards compatible way? It seems like at some point we'll need to deploy a version of the backend that only has one argument and would need to update the front end at the same time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, I was going to deploy this, then change the frontend to only use the new args (e.g. patchId). Do you think that wouldn't work? (I also edited the resolvers) 👀

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible for the front end to only use the new arg? I thought since the query args are order dependent, we'd still need to have null or an empty string as the legacy id argument, which would make it impossible to remove from the backend safely. But I may be wrong 😳

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh!! that's a good point! I tested it out and it seems ok but let me know if it seems wack 🫣

Screenshot 2024-03-26 at 3 02 52 PM Screenshot 2024-03-26 at 3 08 20 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

oh that's awesome, you learn something new every day! thanks for looking into it.

@@ -20,6 +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.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure how I feel about duplicating the same field twice (here and in projectRef.Id, and in other structs). What do you think is the main benefit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh the reason I did this is if we have projectRef.Id or repo.Id, just having Id isn't specific enough to describe what type of input it is. I think we wouldn't be able to put the new directive on the projectRef or repoRef objects because they wouldn't convert properly into a map, and we'd have to put it on the Id field. I'm open to other ideas though!

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah the new directives, that makes perfect sense! Thanks 🤩

Copy link
Contributor

Choose a reason for hiding this comment

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

In #7644 we discussed using projectIdentifier as the key for projectIds do we still want to do that?

Copy link
Contributor Author

@minnakt minnakt Mar 26, 2024

Choose a reason for hiding this comment

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

I'm sort of against it in this case because this input mirrors the RepoSettingsInput, and the repo uses ID (also, the input to this will truly be an ID, and not an identifier)

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense thanks for clarifying!

@minnakt minnakt requested review from sophstad and removed request for a team March 27, 2024 14:45
@minnakt
Copy link
Contributor Author

minnakt commented Mar 28, 2024

removed app review since its probably not necessary

@minnakt minnakt requested a review from khelif96 March 28, 2024 19:26
Copy link
Contributor

@sophstad sophstad left a comment

Choose a reason for hiding this comment

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

just being annoying about existing error messages but looks great!

graphql/query_resolver.go Outdated Show resolved Hide resolved
graphql/query_resolver.go Outdated Show resolved Hide resolved
graphql/query_resolver.go Outdated Show resolved Hide resolved
graphql/query_resolver.go Outdated Show resolved Hide resolved
graphql/query_resolver.go Outdated Show resolved Hide resolved
graphql/query_resolver.go Outdated Show resolved Hide resolved
}
if p != nil {
return false, nil
}
}
return false, ResourceNotFound.Send(ctx, fmt.Sprintf("Unable to find patch or version %s", id))
return false, ResourceNotFound.Send(ctx, fmt.Sprintf("Unable to find patch or version %s", patchId))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return false, ResourceNotFound.Send(ctx, fmt.Sprintf("Unable to find patch or version %s", patchId))
return false, ResourceNotFound.Send(ctx, fmt.Sprintf("finding patch or version '%s'", patchId))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lmao...... turns out I can't update this one because the e2e tests specifically check for this message 🤣 (in pain)

@minnakt minnakt changed the title DEVPROD-5460: Update GraphQL API to support more explicit parameters DEVPROD-5460: Update GraphQL API to support more precise arguments Mar 29, 2024
@minnakt minnakt changed the title DEVPROD-5460: Update GraphQL API to support more precise arguments DEVPROD-5460: Support more precise arguments in GraphQL API Mar 29, 2024
@minnakt minnakt changed the title DEVPROD-5460: Support more precise arguments in GraphQL API DEVPROD-5460: Update GraphQL API with more specific arguments Mar 29, 2024
@minnakt minnakt merged commit 6f0a43f into evergreen-ci:main Mar 29, 2024
8 checks passed
@minnakt minnakt deleted the DEVPROD-5460 branch March 29, 2024 18:03
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