{"action":"created","issue":{"url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/31","labels_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/31/comments","events_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/31/events","html_url":"https://github.com/rmosolgo/graphql-ruby/issues/31","id":104015297,"number":31,"title":"Validation breaking with variables sent by Relay","user":{"login":"sgwilym","id":579491,"avatar_url":"https://avatars.githubusercontent.com/u/579491?v=3","gravatar_id":"","url":"https://api.github.com/users/sgwilym","html_url":"https://github.com/sgwilym","followers_url":"https://api.github.com/users/sgwilym/followers","following_url":"https://api.github.com/users/sgwilym/following{/other_user}","gists_url":"https://api.github.com/users/sgwilym/gists{/gist_id}","starred_url":"https://api.github.com/users/sgwilym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgwilym/subscriptions","organizations_url":"https://api.github.com/users/sgwilym/orgs","repos_url":"https://api.github.com/users/sgwilym/repos","events_url":"https://api.github.com/users/sgwilym/events{/privacy}","received_events_url":"https://api.github.com/users/sgwilym/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":21,"created_at":"2015-08-31T09:11:03Z","updated_at":"2015-09-15T10:28:10Z","closed_at":"2015-09-15T10:28:10Z","body":"I'm not sure if this is an issue with this gem or `graphql-relay-ruby`, but when querying a connection field with an EnumType argument, `graphql-ruby` breaks without an error message, and raises the following:\r\n\r\n`undefined method 'type' for nil:NilClass`\r\n\r\nThis error is being raised from `/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb:36:in validate_usage`\r\n\r\nThis is because the caller of this method in the same file, `validate`, is setting `var_defn_ast` to `nil`, presumably because `declared_variables[node.value.name]` doesn't actually return anything (it's empty).\r\n\r\nAnd when inspecting `node` here, it can be seen that it doesn’t even have a `variables` key:\r\n\r\n```#<GraphQL::Language::Nodes::Argument:0x007fb2a75f3870 @name=\"status\", @value=#<GraphQL::Language::Nodes::VariableIdentifier:0x007fb2a34624b0 @name=\"status_0\", @line=23, @col=44>, @line=23, @col=36>```\r\n\r\nBelow are the breaking query and variable params:\r\n\r\n```\r\nquery Landing {\r\n    viewer{\r\n        ..._0spmx34\r\n      }\r\n    }\r\n    fragment _18n1pkt on Comic {\r\n      title,\r\n      slug,\r\n      author {\r\n        name,\r\n        username,\r\n        id\r\n      },\r\n      coverPage {\r\n        aspectRatio,\r\n        _imageqpcky9:image(size:\\\"thumb\\\") {\r\n          uri\r\n        },\r\n        id},\r\n      id\r\n    }\r\n    fragment _0spmx34 on Viewer {\r\n      _comics56iyr5:comics(first:5,status:$status_0) {\r\n        edges {\r\n          node {\r\n            id,\r\n            coverPage {\r\n              aspectRatio,\r\n              _imageqpcky9:image(size:\\\"thumb\\\") {\r\n                uri\r\n              },\r\n              id\r\n            },\r\n            ..._18n1pkt\r\n          },\r\n          cursor\r\n        },\r\n        pageInfo {\r\n          hasNextPage,\r\n          hasPreviousPage\r\n        }\r\n      }\r\n    }\r\n```\r\n\r\n```{\"status_0\" => \"PUBLISHED\"}```\r\n\r\n And just in case I'm defining something wrong, here’s my `ViewerType`:\r\n\r\n```ruby\r\nViewerType = GraphQL::ObjectType.define do\r\n\r\n  name \"Viewer\"\r\n  description \"This is a workaround type for Relay's inability to handle root fields with more than one argument.\"\r\n\r\n  connection :comics, ComicType.connection_type do\r\n\r\n    argument :status, ComicStatusEnum, \"The status of the requested comics\"\r\n\r\n    resolve -> (obj, args, ctx) {\r\n      if args[\"status\"]\r\n        Comic.where(status: args['status'])\r\n      else\r\n        Comic.all\r\n      end\r\n    }\r\n  end\r\n\r\nend\r\n```\r\n\r\nLet me know if this is something that was never going to work in the first place 😅\r\n"},"comment":{"url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/comments/140347985","html_url":"https://github.com/rmosolgo/graphql-ruby/issues/31#issuecomment-140347985","issue_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/31","id":140347985,"user":{"login":"sgwilym","id":579491,"avatar_url":"https://avatars.githubusercontent.com/u/579491?v=3","gravatar_id":"","url":"https://api.github.com/users/sgwilym","html_url":"https://github.com/sgwilym","followers_url":"https://api.github.com/users/sgwilym/followers","following_url":"https://api.github.com/users/sgwilym/following{/other_user}","gists_url":"https://api.github.com/users/sgwilym/gists{/gist_id}","starred_url":"https://api.github.com/users/sgwilym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgwilym/subscriptions","organizations_url":"https://api.github.com/users/sgwilym/orgs","repos_url":"https://api.github.com/users/sgwilym/repos","events_url":"https://api.github.com/users/sgwilym/events{/privacy}","received_events_url":"https://api.github.com/users/sgwilym/received_events","type":"User","site_admin":false},"created_at":"2015-09-15T10:28:10Z","updated_at":"2015-09-15T10:28:10Z","body":"That fixed it! 🎉"}}