Skip to content

Improve returning data and errors from request #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test_on_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:

- name: Install dependencies
run: |
tarantoolctl rocks install luatest 0.5.2
tarantoolctl rocks install luacheck 0.25.0
tarantoolctl rocks install luatest 0.5.5
tarantoolctl rocks install luacheck 0.26.0
tarantoolctl rocks make

- name: Run linter
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
.doctrees
__pycache__
/dev
/tmp
/tmp/*
!/tmp/.keep
doc
release
release-doc
Expand All @@ -27,4 +28,4 @@ luacov.*.out*
/package-lock.json
*.mo
.history
.vscode
*.rock
6 changes: 6 additions & 0 deletions .luacov
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
statsfile = 'tmp/luacov.stats.out'
reportfile = 'tmp/luacov.report.out'
exclude = {
'/test/',
'/tmp/',
}
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
SHELL := /bin/bash

.PHONY: .rocks
.rocks: graphql-scm-1.rockspec Makefile
tarantoolctl rocks make
tarantoolctl rocks install luatest 0.5.5
tarantoolctl rocks install luacov 0.13.0
tarantoolctl rocks install luacheck 0.26.0

.PHONY: lint
lint:
if [ ! -d ".rocks" ]; then make .rocks; fi
.rocks/bin/luacheck .

.PHONY: test
test: lint
rm -f tmp/luacov*
.rocks/bin/luatest --verbose --coverage --shuffle group
.rocks/bin/luacov . && grep -A999 '^Summary' tmp/luacov.report.out

.PHONY: clean
clean:
rm -rf .rocks

.PHONY: build
build:
if [ ! -d ".rocks" ]; then make .rocks; fi
tarantoolctl rocks make
tarantoolctl rocks pack graphql scm-1
13 changes: 7 additions & 6 deletions graphql/execute.lua
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ local function getFieldEntry(objectType, object, fields, context)
if argument and argument.value then
positions[pos] = {
name=argument.name.value,
value=arguments[argument.name.value]
value=arguments[argument.name.value],
}
pos = pos + 1
end
Expand Down Expand Up @@ -313,7 +313,6 @@ end

evaluateSelections = function(objectType, object, selections, context)
local result = {}
local errors
local err
local fields = collectFields(objectType, selections, {}, {}, context)
for _, field in ipairs(fields) do
Expand All @@ -322,14 +321,14 @@ evaluateSelections = function(objectType, object, selections, context)
result[field.name], err = getFieldEntry(objectType, object, {field.selection},
context)
if err ~= nil then
errors = errors or {}
table.insert(errors, err)
context.errors = context.errors or {}
table.insert(context.errors, err)
end
if result[field.name] == nil then
result[field.name] = box.NULL
end
end
return result, errors
return result, context.errors
end

local function execute(schema, tree, rootValue, variables, operationName)
Expand All @@ -346,4 +345,6 @@ local function execute(schema, tree, rootValue, variables, operationName)
end


return {execute=execute}
return {
execute=execute,
}
Loading