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

examples: adds crud example #368

Merged
merged 1 commit into from
Jul 24, 2018
Merged

examples: adds crud example #368

merged 1 commit into from
Jul 24, 2018

Conversation

maxchagin
Copy link

No description provided.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 91.765% when pulling 8a295fb on maxchagin:master into 2800ba0 on graphql-go:master.

if int64(id) == p.ID {
product = products[i]
// Remove from product list
products = append(products[:i], products[i+1:]...)
Copy link
Member

Choose a reason for hiding this comment

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

Here is better to use something like Filtering without allocating when removing items within a loop, just as general recommendation.

productsUpdated := products[:0]
for _, p := range products {
  if int64(id) != p.ID {
    productsUpdated = append(productsUpdated, p)
  }
}

Copy link
Member

@chris-ramon chris-ramon left a comment

Choose a reason for hiding this comment

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

This is a really great CRUD simple example! — thanks a lot @maxchagin 👍, let's merge it an improve the recomendations in a new upcoming PRs

@chris-ramon chris-ramon merged commit 2b97f4c into graphql-go:master Jul 24, 2018
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