ethe / pygraphy

A modern Pythonic GraphQL implementation.
MIT License
92 stars 13 forks source link

Unsupported Input Variables #18

Closed ethe closed 5 years ago

ethe commented 5 years ago

via #16

Thanks for fix this problem, but it still seems to have some little problem.

Here is my test code, use the last complex_example code with FastAPI -> https://gist.github.com/chiaki64/e5168279926f0cadeacba59f78c5eb2c

and the query string in playground

# Query
query Address($geo: GeoInput!) {
  address(geo: $geo) {
    latlng
  }
}

# Variables
{
  "geo": {
    "lat": 1.0,
    "lng": 2.0
  }
}

# Response
{
  "error": {
    "errors": [
      {
        "message": "'dict' object has no attribute 'body'",
        "locations": null,
        "path": null
      }
    ],
    "data": {}
  }
}

The debug logger shows

ERROR: 'dict' object has no attribute 'body'
Traceback (most recent call last):
  File ".../virtualenvs/uta-D0zEo0Dl/lib/python3.7/site-packages/pygraphy/types/schema.py", line 185, in _execute_operation
    error_collector
  File ".../virtualenvs/uta-D0zEo0Dl/lib/python3.7/site-packages/pygraphy/types/object.py", line 113, in _resolve
    kwargs = self.__package_args(node, field, path)
  File ".../virtualenvs/uta-D0zEo0Dl/lib/python3.7/site-packages/pygraphy/types/object.py", line 261, in __package_args
    arg.value, slot
  File ".../virtualenvs/uta-D0zEo0Dl/lib/python3.7/site-packages/pygraphy/types/base.py", line 103, in load_literal_value
    node = parse_value(variables[name])
  File ".../virtualenvs/uta-D0zEo0Dl/lib/python3.7/site-packages/graphql/language/parser.py", line 120, in parse_value
    expect_token(lexer, TokenKind.SOF)
  File ".../virtualenvs/uta-D0zEo0Dl/lib/python3.7/site-packages/graphql/language/parser.py", line 1073, in expect_token
    lexer.advance()
  File ".../virtualenvs/uta-D0zEo0Dl/lib/python3.7/site-packages/graphql/language/lexer.py", line 85, in advance
    token = self.token = self.lookahead()
  File ".../virtualenvs/uta-D0zEo0Dl/lib/python3.7/site-packages/graphql/language/lexer.py", line 93, in lookahead
    token.next = self.read_token(token)
  File ".../virtualenvs/uta-D0zEo0Dl/lib/python3.7/site-packages/graphql/language/lexer.py", line 108, in read_token
    body = source.body
AttributeError: 'dict' object has no attribute 'body'

the source variable type there should be <class 'graphql.language.source.Source'>, but now we get the type <class 'dict'>, so is this a problem of graphql package or pygraphy package?

ethe commented 5 years ago

Fixed