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

Remove typenames from MockedProvider #1001

Merged
merged 1 commit into from Aug 24, 2017

Conversation

Projects
None yet
4 participants
@Carlows
Copy link
Contributor

Carlows commented Aug 19, 2017

This PR allows to pass a removeTypenames prop to the MockedProvider, this way there's no need to add the __typename field to the mocked data.

Right now, to add mocked data in tests, it's required to use addTypenameToDocument in all of the queries:

const query = addTypenameToDocument(HERO_QUERY);

Together with this, the mocked data needs to include the __typename field in all of the models:

export const hero_no_friends = {
  __typename: 'Droid',
  name: 'r2d2',
  id: '1',
  friends: null,
};

I find this a bit of a pain, and I would prefer not having to do this. As the apollo-client accepts an addTypename field, we can allow the MockedProvider to configure that option as we'd like.

This can be used this like this:

<MockedProvider mocks={mocks} removeTypename>

I didn't find any tests for test-utils, so I only added an example test within the base example.

@meteor-bot

This comment has been minimized.

Copy link

meteor-bot commented Aug 19, 2017

@Carlows: 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/

@mention-bot

This comment has been minimized.

Copy link

mention-bot commented Aug 19, 2017

@Carlows, thanks for your PR! By analyzing the history of the files in this pull request, we identified @jbaxleyiii, @calebmer and @mmissey to be potential reviewers.

@meteor-bot

This comment has been minimized.

Copy link

meteor-bot commented Aug 19, 2017

Warnings
⚠️

There are library changes, but not tests. That's OK as long as you're refactoring existing code

Generated by 🚫 dangerJS

Carlos Martinez
Remove typename from MockedProvider
This commit allows to pass a removeTypenames prop to the MockedProvider,
this way there's no need to add the __typename field to the mocked data.

@Carlows Carlows force-pushed the Carlows:master branch from b7e6c57 to c21b7ac Aug 19, 2017

@jbaxleyiii

This comment has been minimized.

Copy link
Member

jbaxleyiii commented Aug 24, 2017

@Carlows this is such a great addition 😍

Thank you! And congrats on your first contribution here!

@jbaxleyiii jbaxleyiii merged commit 3f4da58 into apollographql:master Aug 24, 2017

4 checks passed

CLA Author has signed the Meteor CLA.
Details
Danger ⚠️ Danger found some issues. Don't worry, everything is fixable.
Details
bundlesize ./dist/index.min.js: 11.82kB < maxSize 12kB gzip (same as master)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment