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

to use forEach instead of map function in with-apollo example #37283

Closed
1 task done
ArianHamdi opened this issue May 29, 2022 · 1 comment · Fixed by #37284
Closed
1 task done

to use forEach instead of map function in with-apollo example #37283

ArianHamdi opened this issue May 29, 2022 · 1 comment · Fixed by #37284
Labels
bug Issue was opened via the bug report template.

Comments

@ArianHamdi
Copy link
Contributor

ArianHamdi commented May 29, 2022

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

Not relevant

Which example does this report relate to?

with-apollo

Describe the Bug

There is no bug but it is better to use forEach function instead of map function because we don't care about the value that is retunded by map function.

const errorLink = onError(({ graphQLErrors, networkError }) => {
  if (graphQLErrors)
    graphQLErrors.map(({ message, locations, path }) =>
      console.log(
        `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
      )
    )
  if (networkError) console.log(`[Network error]: ${networkError}`)
})

Expected Behavior

const errorLink = onError(({ graphQLErrors, networkError }) => {
  if (graphQLErrors)
    graphQLErrors.forEach(({ message, locations, path }) =>
      console.log(
        `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
      )
    )
  if (networkError) console.log(`[Network error]: ${networkError}`)
})

To Reproduce

clone with-apollo example and look at lib/apolloClient.js

@ArianHamdi ArianHamdi added the bug Issue was opened via the bug report template. label May 29, 2022
ArianHamdi added a commit to ArianHamdi/next.js that referenced this issue May 29, 2022
@kodiakhq kodiakhq bot closed this as completed in #37284 May 29, 2022
kodiakhq bot pushed a commit that referenced this issue May 29, 2022
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant