Skip to content
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

fix: mutation_root_name when there is no mutation type #2

Merged
merged 1 commit into from Dec 5, 2016

Conversation

dylanahsmith
Copy link
Contributor

@mikkoh please review

Problem

I get the following exception when there is no GraphQL mutation type:

NoMethodError: undefined method `fetch' for nil:NilClass
    /Users/dylansmith/src/graphql_schema/lib/graphql_schema.rb:18:in `mutation_root_name'
    /Users/dylansmith/src/graphql_schema/test/graphql_schema_test.rb:25:in `test_no_mutation_root'

because the default argument to fetch in mutation_root_name (i.e. @hash.fetch('mutationType', {})) wasn't being used since the mutationType key exists, it is just nil.

Solution

Use a condition to only call .fetch('name') if the mutation type is truthy.

Copy link
Member

@mikkoh mikkoh left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@dylanahsmith dylanahsmith merged commit 987cdb2 into master Dec 5, 2016
@dylanahsmith dylanahsmith deleted the no-mutation-root branch December 5, 2016 17:36
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.

None yet

2 participants