-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Discriminators): copying base
InputTypes
to base resolver `ArgT…
…ypes` * test(discriminator): add more test cases for `mergeCustomizationOptions()` * fix: fix copying base `InputTypes` to copying base resolver `ArgTypes` Refactor: rename fn `setBaseInputTypesOnChildInputTypes` to `copyResolverArgTypes` * test(discriminator): add more test cases for customization Options
- Loading branch information
Showing
5 changed files
with
128 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/discriminators/__tests__/prepareChildResolvers-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* @flow */ | ||
|
||
import { schemaComposer } from 'graphql-compose'; | ||
import { getCharacterModels } from '../__mocks__/characterModels'; | ||
import { composeWithMongooseDiscriminators } from '../../composeWithMongooseDiscriminators'; | ||
|
||
const { CharacterModel, PersonModel } = getCharacterModels('type'); | ||
|
||
describe('prepareChildResolvers()', () => { | ||
describe('copyResolverArgTypes()', () => { | ||
afterAll(() => { | ||
schemaComposer.clear(); | ||
}); | ||
// Note childResolver Arg fields are copied from baseResolver | ||
const baseDTC = composeWithMongooseDiscriminators(CharacterModel, { | ||
resolvers: { | ||
createOne: { | ||
requiredFields: ['kind'], | ||
}, | ||
}, | ||
}); | ||
const PersonTC = baseDTC.discriminator(PersonModel); | ||
|
||
it('should copy base common ResolverArgTypes to child', () => { | ||
expect( | ||
baseDTC | ||
.getResolver('createOne') | ||
.getArgTC('record') | ||
.getFieldType('kind') | ||
).toEqual( | ||
PersonTC.getResolver('createOne') | ||
.getArgTC('record') | ||
.getFieldType('kind') | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters