pothos icon indicating copy to clipboard operation
pothos copied to clipboard

Object Type mocks

Open Jomik opened this issue 3 years ago • 1 comments

The idea is to be able to mock certain returned objects whenever they are seen in the schema.

const DroidMock = createObjectMock('Droid', (...) => fakeDroid);

const mockedSchema = builder.toSchema({
  typeMocks: [DroidMock],
});

It would be really amazing if our mock resolver could get some sensible arguments, like the id of the object being resolved, if using dataloader/relay node. I sadly do not think that is possible, given that we have to run the resolver that we try to wrap, to figure out if it is an id or a full object, and that is probably not what is wanted in most cases. It would also be nice if we were able to be a bit more clever or dynamic with the length of the lists that are requested, but I have found no good way for that.

Jomik avatar Feb 12 '22 14:02 Jomik

⚠️ No Changeset found

Latest commit: 04e70a381c42c7415eee0a1a4c36ca9314851b29

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Feb 12 '22 14:02 changeset-bot[bot]