Skip to content

Enforce Oneof behavior at execution time#3

Open
erikkessler1 wants to merge 3 commits intooneof-validationfrom
oneof-execution
Open

Enforce Oneof behavior at execution time#3
erikkessler1 wants to merge 3 commits intooneof-validationfrom
oneof-execution

Conversation

@erikkessler1
Copy link
Copy Markdown
Owner

This enforces the behavior of Oneof Input Object and Oneof Objects during the execution phase of fulfilling a GraphQL request.

Comment thread src/execution/__tests__/oneof-test.ts Outdated
describe('Execute: Handles Oneof Input Objects and Oneof Objects', () => {
describe('Oneof Input Objects', () => {
const rootValue = {
test() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these tests echo back the oneOf input object argument rather than returning a hard coded literal to ensure the inputs make it all the way through the resolvers?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call.

},
};

it('accepts a good default value', () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need test coverage for field argument defaults and input object input field defaults that use oneOf input objects?

EDIT: I guess the validation for those scenarios is still pending based on graphql#3049.

);
expectValueFrom('{ requiredBool: null }', testInputObj).to.equal(undefined);
expectValueFrom('{ bool: true }', testInputObj).to.equal(undefined);
expectValueFrom('{ a: "abc" }', testOneOfInputObj).to.deep.equal({
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth testing a oneOf input object with one key that has a value that can't be coerced e.g. {a: 1}?

This ensures that we enforce the rules for Oneof Input Objects at
execution time.
This ensures the Oneof Objects resolve to an object with exactly one
non-null entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants