Skip to content

Prevent redefining pendingApolloRequests in lib/graphql.js

What does this MR do and why?

The MR will check if the pendingApolloRequests has been already defined before redefining it in ~/lib/graphql.js.

Why?

Tests might fail when an imported file tries to reimport ~/lib/graphql.js and the test will fail with such errors:

TypeError: Cannot redefine property: pendingApolloRequests
      at Function.defineProperty (<anonymous>)
      at Object.defineProperty (app/assets/javascripts/lib/graphql.js:125:8)
      at Object.require (app/assets/javascripts/emoji/index.js:5:1)
      at Object.require (app/assets/javascripts/members/components/avatars/user_avatar.vue:19:10)
      at Object.require (ee/app/assets/javascripts/members/promotion_requests/components/app.vue:25:39)
      at Object.require (ee/app/assets/javascripts/members/constants.js:13:1)
      at Object.require (ee/spec/frontend/members/mock_data.js:2:1)

We could try to mock or fix the test itself, but adding the condition before defining the property seems like a long-term solution.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

N/A

How to set up and validate locally

  • Navigate to a page that uses the library (most pages do, e.g. assigning an issue to a user)
  • Make sure everything is working and no errors in the console
Edited by Ammar Alakkad

Merge request reports