diff --git a/graphene_django_optimizer/query.py b/graphene_django_optimizer/query.py
index 3f37d055e9317401d3c0294669e767708fd85fdb..256ad684868b8d3c30e8de4a5b0ac34a211ad249 100644
--- a/graphene_django_optimizer/query.py
+++ b/graphene_django_optimizer/query.py
@@ -13,6 +13,7 @@ from graphql.execution.base import (
 from graphql.language.ast import (
     FragmentSpread,
     InlineFragment,
+    Variable
 )
 from graphql.type.definition import (
     GraphQLInterfaceType,
@@ -180,7 +181,17 @@ class QueryOptimizer(object):
             self._get_type(field_def),
             parent_type,
         )
-        args = tuple(arg.value.value for arg in selection.arguments)
+
+        args = []
+        for arg in selection.arguments:
+            if isinstance(arg.value, Variable):
+                var_name = arg.value.name.value
+                value = info.variable_values.get(var_name)
+            else:
+                value = arg.value.value
+            args.append(value)
+        args = tuple(args)
+
         self._add_optimization_hints(
             optimization_hints.select_related(info, *args),
             store.select_list,
@@ -336,7 +347,6 @@ def _get_path_from_parent(self, parent):
     chain.append(model)
     # Construct a list of the PathInfos between models in chain.
     path = []
-    import ipdb; ipdb.set_trace()
     for i, ancestor in enumerate(chain[:-1]):
         child = chain[i + 1]
         link = child._meta.get_ancestor_link(ancestor)
diff --git a/tests/schema.py b/tests/schema.py
index d6dd992d50fdcb4b2fc795a4ebebe5ee65ada7ea..1b2a082d6f6f50d4d0185cc3e1a474402f5fe7cf 100644
--- a/tests/schema.py
+++ b/tests/schema.py
@@ -64,6 +64,10 @@ class BaseItemType(DjangoObjectType):
         graphene.Field('tests.schema.ItemType'),
         model_field='parent',
     )
+    relay_all_children = gql_optimizer.field(
+        DjangoConnectionField('tests.schema.ItemNode'),
+        model_field='children'
+    )
 
     class Meta:
         model = Item
diff --git a/tests/test_relay.py b/tests/test_relay.py
index b50f09a35fd9b0beda9abd141aa5a50f6210d787..a8377458494e99707c6828788b50850d6327ef13 100644
--- a/tests/test_relay.py
+++ b/tests/test_relay.py
@@ -145,3 +145,28 @@ def test_should_work_fine_with_page_info_field_below_edges_field_when_only_optim
     ''')
     assert not result.errors
     assert result.data['relayItems']['pageInfo']['hasNextPage'] is True
+
+
+@pytest.mark.django_db
+def test_resolve_nested_variables():
+    item_1 = Item.objects.create(id=7, name='foo')
+    item_1.children.create(id=8, name='bar')
+    variables = {'items_first': 1, 'schema_first': 1}
+    result = schema.execute('''
+        query Query($itemsFirst: Int, $childrenFirst: Int) {
+            relayItems(first: $itemsFirst) {
+                edges {
+                    node {
+                        relayAllChildren(first: $childrenFirst) {
+                            edges {
+                                node {
+                                    id
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    ''', variables=variables)
+    assert not result.errors