Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

[Feature Request] Insert dynamicVariables at mocked provider #2467

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

gabrieluizramos
Copy link

@gabrieluizramos gabrieluizramos commented Oct 3, 2018

This PR updates MockedProvider test-link validation, inserting a new field dynamicVariables on the mockeds request array, such as:

const mocks = [{
  request: {
    query: myQuery
  },
  result: {
    data: {
      myQuery: {
        lead: {
          pk: 1
        },
        errors: [{
          field: 'email',
          message: 'beibe beibe do beibe do biruleibe leibe'
        }],
        success: false
      }
    }
  },
  dynamicVariables: true
}];

Providing an environment where dynamic variables are necessary in tests and storybooks using MockedProvider.

As opened issue 2466

@apollo-cla
Copy link

@gabrieluizramos: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@gabrieluizramos gabrieluizramos changed the title [WIP][Feature Request] Insert dynamicVariables at mocked provider [Feature Request] Insert dynamicVariables at mocked provider Oct 3, 2018
@gabrieluizramos
Copy link
Author

gabrieluizramos commented Oct 19, 2018

@hwillson Hi! Could help me with this PR (and Feature request), please? :)

@hwillson
Copy link
Member

hwillson commented Mar 6, 2019

Thanks for submitting this PR @gabrieluizramos. Unfortunately, this isn't something we're able to accept at this time. The matching of exact variables that are being sent in via the request, with variables that have been defined in the mocked response, is intentional and isn't something we want to support a workaround for at this time. To achieve the same functionality you're looking for in
https://codesandbox.io/s/w27mz5r44w, can you not just drop the variables being sent into your this.props.mutate() call? This will have the same affect as your proposed dynamicVariables change. Thanks again!

@hwillson hwillson closed this Mar 6, 2019
@hwillson
Copy link
Member

hwillson commented Apr 10, 2019

@gabrieluizramos We're interested in re-visiting this, so I'll re-open this PR. Instead of using the current dynamicVariables: true approach, we're considering allowing a variable matcher function to be set, that can be a bit more specific. We'll add some changes to this PR shortly - thanks for kickstarting things!

@hwillson hwillson reopened this Apr 10, 2019
@gabrieluizramos
Copy link
Author

@hwillson thank you for re-visiting this feature! I'm glad to help you guys 😄

@hwillson hwillson self-assigned this Apr 10, 2019
@hwillson hwillson removed this from Backlog in React Apollo Apr 10, 2019
@hwillson hwillson added this to the Release 3.1 milestone Jun 17, 2019
@hwillson hwillson removed their assignment Aug 5, 2019
@hwillson hwillson removed this from the Release 3.1 milestone Sep 6, 2019
@gabrieluizramos
Copy link
Author

gabrieluizramos commented Feb 7, 2020

@hwillson Hi there! Do you think that this still interesting for you guys?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants