Repository: mirumee/ariadne

Issue:
Exception in default_literal_parser() when ValueNode has no "value" member
The [default_literal_parser() function](https://github.com/mirumee/ariadne/blob/master/ariadne/scalars.py#L90) in ariadne.scalars expects nodes to have a "value" member.  However, this is not the case with, for example, `ObjectValueNode` or `ListValueNode`.  This causes an exception when trying to pass such nodes.

My suggestion is to use `graphql.utilities.value_from_ast_untyped` instead:
```
return value_parser(value_from_ast_untyped(ast))
``` 

I'm happy to do a PR if you guys like this change.

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/mirumee/ariadne/pull/357?src=pr&el=h1) Report
> Merging [#357](https://codecov.io/gh/mirumee/ariadne/pull/357?src=pr&el=desc) into [master](https://codecov.io/gh/mirumee/ariadne/commit/cdc74bf6db821c702836be9e787b7bbe0113467b&el=desc) will **decrease** coverage by `0.04%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/mirumee/ariadne/pull/357/graphs/tree.svg?width=650&height=150&src=pr&token=8GSRgVxHd7)](https://codecov.io/gh/mirumee/ariadne/pull/357?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #357      +/-   ##
==========================================
- Coverage   98.10%   98.06%   -0.05%     
==========================================
  Files         104      104              
  Lines        5007     4903     -104     
==========================================
- Hits         4912     4808     -104     
  Misses         95       95              
```


| [Impacted Files](https://codecov.io/gh/mirumee/ariadne/pull/357?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [ariadne/scalars.py](https://codecov.io/gh/mirumee/ariadne/pull/357/diff?src=pr&el=tree#diff-YXJpYWRuZS9zY2FsYXJzLnB5) | `100.00% <100.00%> (ø)` | |
| [tests/test\_custom\_scalars.py](https://codecov.io/gh/mirumee/ariadne/pull/357/diff?src=pr&el=tree#diff-dGVzdHMvdGVzdF9jdXN0b21fc2NhbGFycy5weQ==) | `100.00% <100.00%> (ø)` | |
| [tests/conftest.py](https://codecov.io/gh/mirumee/ariadne/pull/357/diff?src=pr&el=tree#diff-dGVzdHMvY29uZnRlc3QucHk=) | `94.44% <0.00%> (-0.56%)` | :arrow_down: |
| [tests/wsgi/conftest.py](https://codecov.io/gh/mirumee/ariadne/pull/357/diff?src=pr&el=tree#diff-dGVzdHMvd3NnaS9jb25mdGVzdC5weQ==) | `97.61% <0.00%> (-0.46%)` | :arrow_down: |
| [tests/federation/test\_interfaces.py](https://codecov.io/gh/mirumee/ariadne/pull/357/diff?src=pr&el=tree#diff-dGVzdHMvZmVkZXJhdGlvbi90ZXN0X2ludGVyZmFjZXMucHk=) | `94.00% <0.00%> (-0.12%)` | :arrow_down: |
| [ariadne/file\_uploads.py](https://codecov.io/gh/mirumee/ariadne/pull/357/diff?src=pr&el=tree#diff-YXJpYWRuZS9maWxlX3VwbG9hZHMucHk=) | `98.18% <0.00%> (-0.10%)` | :arrow_down: |
| [tests/test\_directives.py](https://codecov.io/gh/mirumee/ariadne/pull/357/diff?src=pr&el=tree#diff-dGVzdHMvdGVzdF9kaXJlY3RpdmVzLnB5) | `97.56% <0.00%> (-0.02%)` | :arrow_down: |
| [tests/test\_enums.py](https://codecov.io/gh/mirumee/ariadne/pull/357/diff?src=pr&el=tree#diff-dGVzdHMvdGVzdF9lbnVtcy5weQ==) | `100.00% <0.00%> (ø)` | |
| [tests/test\_unions.py](https://codecov.io/gh/mirumee/ariadne/pull/357/diff?src=pr&el=tree#diff-dGVzdHMvdGVzdF91bmlvbnMucHk=) | `100.00% <0.00%> (ø)` | |
| [ariadne/extensions.py](https://codecov.io/gh/mirumee/ariadne/pull/357/diff?src=pr&el=tree#diff-YXJpYWRuZS9leHRlbnNpb25zLnB5) | `100.00% <0.00%> (ø)` | |
| ... and [26 more](https://codecov.io/gh/mirumee/ariadne/pull/357/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/mirumee/ariadne/pull/357?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/mirumee/ariadne/pull/357?src=pr&el=footer). Last update [cdc74bf...c915d7f](https://codecov.io/gh/mirumee/ariadne/pull/357?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

markedwards: @rafalp let me know if I need to do anything else to wrap this up.  Thanks!

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 13ca89f..d0b316d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
 
 - Added `validation_rules` option to query executors as well as ASGI and WSGI apps and Django view that allow developers to include custom query validation logic in their APIs.
 - Added `validation.cost_validator` query validator that allows developers to limit maximum allowed query cost/complexity.
+- `ScalarType` default literal parser now uses `graphql.utilities.value_from_ast_untyped` to parse the AST.
 
 
 ## 0.11.0 (2020-04-01)
diff --git a/ariadne/scalars.py b/ariadne/scalars.py
index 3838343..60f3f14 100644
--- a/ariadne/scalars.py
+++ b/ariadne/scalars.py
@@ -14,6 +14,7 @@ from graphql.type import (
     GraphQLScalarValueParser,
     GraphQLSchema,
 )
+from graphql.utilities import value_from_ast_untyped
 
 from .types import SchemaBindable
 
@@ -87,6 +88,6 @@ def create_default_literal_parser(
     value_parser: GraphQLScalarValueParser,
 ) -> GraphQLScalarLiteralParser:
     def default_literal_parser(ast):
-        return value_parser(ast.value)
+        return value_parser(value_from_ast_untyped(ast))
 
     return default_literal_parser


Test patch:
diff --git a/tests/test_custom_scalars.py b/tests/test_custom_scalars.py
index 209381a..4b45cb9 100644
--- a/tests/test_custom_scalars.py
+++ b/tests/test_custom_scalars.py
@@ -250,13 +250,13 @@ def test_literal_string_is_deserialized_by_default_parser():
 def test_literal_int_is_deserialized_by_default_parser():
     result = graphql_sync(schema, "{ testInputValueType(value: 123) }")
     assert result.errors is None
-    assert result.data == {"testInputValueType": "str"}
+    assert result.data == {"testInputValueType": "int"}
 
 
 def test_literal_float_is_deserialized_by_default_parser():
     result = graphql_sync(schema, "{ testInputValueType(value: 1.5) }")
     assert result.errors is None
-    assert result.data == {"testInputValueType": "str"}
+    assert result.data == {"testInputValueType": "float"}
 
 
 def test_literal_bool_true_is_deserialized_by_default_parser():
@@ -269,3 +269,15 @@ def test_literal_bool_false_is_deserialized_by_default_parser():
     result = graphql_sync(schema, "{ testInputValueType(value: false) }")
     assert result.errors is None
     assert result.data == {"testInputValueType": "bool"}
+
+
+def test_literal_object_is_deserialized_by_default_parser():
+    result = graphql_sync(schema, "{ testInputValueType(value: {}) }")
+    assert result.errors is None
+    assert result.data == {"testInputValueType": "dict"}
+
+
+def test_literal_list_is_deserialized_by_default_parser():
+    result = graphql_sync(schema, "{ testInputValueType(value: []) }")
+    assert result.errors is None
+    assert result.data == {"testInputValueType": "list"}