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!
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

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.
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"}

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
-e git+https://github.com/mirumee/ariadne.git@cdc74bf6db821c702836be9e787b7bbe0113467b#egg=ariadne
certifi @ file:///croot/certifi_1671487769961/work/certifi
coverage==7.2.7
exceptiongroup==1.2.2
execnet==2.0.2
graphql-core==3.0.3
importlib-metadata==6.7.0
iniconfig==2.0.0
packaging==24.0
pluggy==1.2.0
pytest==7.4.4
pytest-asyncio==0.21.2
pytest-cov==4.1.0
pytest-mock==3.11.1
pytest-xdist==3.5.0
starlette==0.13.2
tomli==2.0.1
typing-extensions==3.7.4.1
zipp==3.15.0

name: ariadne
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - ariadne==0.11.0
      - coverage==7.2.7
      - exceptiongroup==1.2.2
      - execnet==2.0.2
      - graphql-core==3.0.3
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - packaging==24.0
      - pluggy==1.2.0
      - pytest==7.4.4
      - pytest-asyncio==0.21.2
      - pytest-cov==4.1.0
      - pytest-mock==3.11.1
      - pytest-xdist==3.5.0
      - starlette==0.13.2
      - tomli==2.0.1
      - typing-extensions==3.7.4.1
      - zipp==3.15.0
prefix: /opt/conda/envs/ariadne

tests/test_custom_scalars.py::test_literal_int_is_deserialized_by_default_parser tests/test_custom_scalars.py::test_literal_float_is_deserialized_by_default_parser tests/test_custom_scalars.py::test_literal_object_is_deserialized_by_default_parser tests/test_custom_scalars.py::test_literal_list_is_deserialized_by_default_parser
tests/test_custom_scalars.py::test_attempt_bind_scalar_to_undefined_type_raises_error tests/test_custom_scalars.py::test_attempt_bind_scalar_to_invalid_schema_type_raises_error tests/test_custom_scalars.py::test_python_date_is_serialized_by_scalar tests/test_custom_scalars.py::test_literal_with_valid_date_str_is_deserialized_to_python_date tests/test_custom_scalars.py::test_attempt_deserialize_str_literal_without_valid_date_raises_error tests/test_custom_scalars.py::test_attempt_deserialize_wrong_type_literal_raises_error tests/test_custom_scalars.py::test_variable_with_valid_date_string_is_deserialized_to_python_date tests/test_custom_scalars.py::test_attempt_deserialize_str_variable_without_valid_date_raises_error tests/test_custom_scalars.py::test_attempt_deserialize_wrong_type_variable_raises_error tests/test_custom_scalars.py::test_scalar_serializer_can_be_set_on_initialization tests/test_custom_scalars.py::test_scalar_serializer_can_be_set_with_setter tests/test_custom_scalars.py::test_scalar_value_parser_can_be_set_on_initialization tests/test_custom_scalars.py::test_scalar_value_parser_can_be_set_with_setter tests/test_custom_scalars.py::test_scalar_literal_parser_can_be_set_on_initialization tests/test_custom_scalars.py::test_scalar_literal_parser_can_be_set_with_setter tests/test_custom_scalars.py::test_setting_scalar_value_parser_sets_default_literal_parsers_if_none_is_set tests/test_custom_scalars.py::test_setting_scalar_value_parser_doesnt_override_already_set_literal_parser tests/test_custom_scalars.py::test_literal_string_is_deserialized_by_default_parser tests/test_custom_scalars.py::test_literal_bool_true_is_deserialized_by_default_parser tests/test_custom_scalars.py::test_literal_bool_false_is_deserialized_by_default_parser
ariadne/scalars.py CHANGELOG.md
ariadne/scalars.py CHANGELOG.md