From 95b3b32450e1319ba04316c75ed608f0c0d5e2a1 Mon Sep 17 00:00:00 2001 From: Alexander Turenko Date: Thu, 30 Sep 2021 12:28:13 +0300 Subject: [PATCH] Fix directives processing in a fragment definition The problem is that we attach the 'directives' node to a wrong AST tree node. Now it is in the fragment definition node (as should). Overlooked it, my bad. Follows up #2 --- luagraphqlparser/lib.c | 2 +- test/directives_test.lua | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/luagraphqlparser/lib.c b/luagraphqlparser/lib.c index 165fa7b..7953c69 100644 --- a/luagraphqlparser/lib.c +++ b/luagraphqlparser/lib.c @@ -668,7 +668,7 @@ end_visit_fragment_definition(const struct GraphQLAstFragmentDefinition *def, vo lua_pushliteral(L, "directives"); lua_insert(L, -2); - lua_settable(L, -3); + lua_settable(L, -4); } lua_pushliteral(L, "typeCondition"); diff --git a/test/directives_test.lua b/test/directives_test.lua index e1b2df4..f3b0bc6 100755 --- a/test/directives_test.lua +++ b/test/directives_test.lua @@ -45,14 +45,14 @@ function g.test_with_fragment() definitions = { { typeCondition = { - directives = { - {name = {kind = 'name', value = 'foo'}, kind = 'directive'}, - }, name = { kind = 'name', value = 'Y', }, kind = 'namedType', }, + directives = { + {name = {kind = 'name', value = 'foo'}, kind = 'directive'}, + }, selectionSet = { selections = { {name = {kind = 'name', value = 'name'}, kind = 'field'},