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

Use conventions to support GraphQL mutations and adjust query names #513

Merged
merged 6 commits into from
Oct 26, 2024

Conversation

mattjohnsonpint
Copy link
Collaborator

Implements naming conventions for functions that alter how they are represented in the generated GraphQL API:

var queryTrimPrefixes = []string{"get", "list"}
var mutationPrefixes = []string{
	"mutate",
	"post", "patch", "put", "delete",
	"add", "update", "insert", "upsert",
	"create", "edit", "save", "remove", "alter", "modify",
}
  • If a function name starts with a mutation prefix, then it's a mutation, not a query.
  • If a function name starts with a query trim prefix, then it's a query and the prefix will be trimmed away.
  • Otherwise, it's a query.

For example, consider functions named getCustomers, searchInventory, and updateProduct`. They now will get GraphQL schema of:

type Query {
    customers(...)
    searchInventory(...)
}

type Mutation {
    updateProduct(...)
}

@mattjohnsonpint mattjohnsonpint requested a review from a team as a code owner October 26, 2024 00:37
@mattjohnsonpint mattjohnsonpint enabled auto-merge (squash) October 26, 2024 00:43
@mattjohnsonpint mattjohnsonpint merged commit 3f87df6 into main Oct 26, 2024
45 checks passed
@mattjohnsonpint mattjohnsonpint deleted the mjp/hyp-2289-establish-api-naming-conventions branch October 26, 2024 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants