Skip to content

Import patches from tarantool/cartridge #9

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

Merged
merged 35 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
63b56c9
initial import from cartridge
olegrok Feb 11, 2021
7f817bb
Hold order of fields traversal
olegrok Feb 11, 2021
9718dea
allow to pass fieldName in execute
olegrok Feb 11, 2021
7cdfa06
add accessor to nonNull version of lists to list object
olegrok Feb 11, 2021
6925795
Fix graphql coerce: include InputObject field names
olegrok Feb 11, 2021
86721a8
add argument positions
olegrok Feb 11, 2021
8c99d09
add key and value tuple for positioning graphql arguments
olegrok Feb 11, 2021
61b322e
return box.NULL as value if function returns nil
olegrok Feb 11, 2021
59176b2
throw error if second return value from resolver is not nil
olegrok Feb 11, 2021
85fdd49
remove redundant spaces from types description
olegrok Feb 11, 2021
cd3ccc8
Fix graphql.validate.getParentFields
olegrok Feb 11, 2021
6e8c3fa
Optimize graphql resolvers
olegrok Feb 11, 2021
51bbd76
strictly validate GraphQL types
olegrok Feb 11, 2021
6675061
improve verbosity in graphql errors
olegrok Feb 11, 2021
4d4498a
properly handle nested input objects
olegrok Feb 11, 2021
0cc793a
prettify error messages
olegrok Feb 11, 2021
c0f3fc5
enable linting
olegrok Feb 11, 2021
8e66776
couple of bugfixes
olegrok Feb 11, 2021
5963111
support default variables
olegrok Feb 11, 2021
a38744c
fix error messages for output types mismatch
olegrok Feb 11, 2021
c462cb3
show at least object kind in case of null value
olegrok Feb 11, 2021
b0eed4f
allow to specify different schemas for graphql types
olegrok Feb 11, 2021
06a2c1e
fix GraphQL values parsing
olegrok Feb 11, 2021
9e8ed48
drop init file
olegrok Feb 11, 2021
baa9b72
test: drop old tests
olegrok Feb 11, 2021
0d7367c
import unit tests from cartridge
olegrok Feb 11, 2021
d496f10
add gitignore to the project
olegrok Feb 11, 2021
457ba82
add luacheck configuration
olegrok Feb 11, 2021
b91a567
use libgraphqlparser for graphql ast build
olegrok Feb 11, 2021
e37651d
support "null" arguments
olegrok Feb 11, 2021
7be9372
setup tests and linter run in CI
olegrok Feb 12, 2021
a995138
import integration tests from cartridge
olegrok Feb 12, 2021
539b5b5
fix validation for non-nullable arguments
olegrok Feb 15, 2021
ef7dd0f
update readme
olegrok Feb 15, 2021
d01b2d4
add workflow for pushing rockspec/rocks
olegrok Feb 16, 2021
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
27 changes: 27 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish

on:
push:
tags:
- '*'

jobs:
publish:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: tarantool/setup-tarantool@v1
with:
tarantool-version: '2.7'

- run: echo "TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
- run: tarantoolctl rocks new_version --tag $TAG
- run: tarantoolctl rocks pack graphql-$TAG-1.rockspec

- uses: tarantool/rocks.tarantool.org/github-action@master
with:
auth: ${{ secrets.ROCKS_USERNAME }}:${{ secrets.ROCKS_PASSWORD }}
files: |
graphql-${{ env.TAG }}-1.rockspec
graphql-${{ env.TAG }}-1.src.rock
33 changes: 33 additions & 0 deletions .github/workflows/test_on_push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Run tests

on:
push:
pull_request:

jobs:
run-tests-ce:
if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login != 'tarantool'
strategy:
matrix:
tarantool-version: ["1.10", "2.7"]
fail-fast: false
runs-on: [ubuntu-20.04]
steps:
- uses: actions/checkout@v2
- uses: tarantool/setup-tarantool@v1
with:
tarantool-version: ${{ matrix.tarantool-version }}

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

- name: Run linter
run: .rocks/bin/luacheck .

- name: Run tests
run: .rocks/bin/luatest -v
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.~*
*~
.tarantool.cookie
.rocks
.cache
.doctrees
__pycache__
/dev
/tmp
doc
release
release-doc
.idea
Dockerfile.test
Makefile.test
CMakeFiles
CMakeCache.txt
cmake_install.cmake
CTestTestfile.cmake
build.luarocks
build.rst
coverage_result.txt
.DS_Store
.vscode
luacov.*.out*
/node_modules
/package-lock.json
*.mo
18 changes: 18 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
redefined = false
include_files = {
'*.lua',
'test/**/*.lua',
'graphql/**/*.lua',
'*.rockspec',
'.luacheckrc',
}
exclude_files = {
'.rocks',
}
new_read_globals = {
box = { fields = {
session = { fields = {
storage = {read_only = false, other_fields = true}
}}
}}
}
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
Lua implementation of GraphQL for Tarantool
===========================================

Lua implementation of GraphQL for Tarantool. It is based on [graphql-lua](https://github.com/bjornbytes/graphql-lua).
Lua implementation of GraphQL for Tarantool.
It is based on [graphql-lua](https://github.com/bjornbytes/graphql-lua).


Installation
------------

```bash
tarantoolctl rocks install https://github.com/raw/tarantool/graphql/master/graphql-scm-1.rockspec
tarantoolctl rocks install graphql
```

Example
---

```lua
local parse = require 'graphql.parse'
local schema = require 'graphql.schema'
local types = require 'graphql.types'
local validate = require 'graphql.validate'
local execute = require 'graphql.execute'
local parse = require('graphql.parse')
local schema = require('graphql.schema')
local types = require('graphql.types')
local validate = require('graphql.validate')
local execute = require('graphql.execute')

-- Parse a query
local ast = parse [[
Expand All @@ -32,7 +33,7 @@ query getUser($id: ID) {
]]

-- Create a type
local Person = types.object {
local Person = types.object({
name = 'Person',
fields = {
id = types.id.nonNull,
Expand All @@ -41,11 +42,11 @@ local Person = types.object {
lastName = types.string.nonNull,
age = types.int.nonNull
}
}
})

-- Create a schema
local schema = schema.create {
query = types.object {
local schema = schema.create({
query = types.object({
name = 'Query',
fields = {
person = {
Expand All @@ -65,8 +66,8 @@ local schema = schema.create {
end
}
}
}
}
})
})

-- Validate a parsed query against a schema
validate(schema, ast)
Expand All @@ -91,21 +92,20 @@ execute(schema, ast, rootValue, variables, operationName)
Status
---

- [x] Parsing
- [ ] Improve error messages
- [x] Parsing (based on [luagraphqlparser](https://github.com/tarantool/luagraphqlparser))
- [x] Type system
- [x] Introspection
- [x] Validation
- [x] Execution
- [ ] Asynchronous execution (coroutines)
- [ ] Example server

Running tests
---

```bash
tarantoolctl rocks make # optionally
tarantool tests/runner.lua
tarantoolctl rocks make
tarantoolctl rocks install luatest 0.5.2
.rocks/bin/luatest
```

License
Expand Down
15 changes: 8 additions & 7 deletions graphql-scm-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@ description = {

dependencies = {
'lua >= 5.1',
'lulpeg',
'luagraphqlparser == 0.1.0-1',
}

build = {
type = 'builtin',
modules = {
['graphql'] = 'graphql/init.lua',
['graphql.parse'] = 'graphql/parse.lua',
['graphql.types'] = 'graphql/types.lua',
['graphql.execute'] = 'graphql/execute.lua',
['graphql.introspection'] = 'graphql/introspection.lua',
['graphql.parse'] = 'graphql/parse.lua',
['graphql.query_util'] = 'graphql/query_util.lua',
['graphql.rules'] = 'graphql/rules.lua',
['graphql.schema'] = 'graphql/schema.lua',
['graphql.types'] = 'graphql/types.lua',
['graphql.util'] = 'graphql/util.lua',
['graphql.validate'] = 'graphql/validate.lua',
['graphql.rules'] = 'graphql/rules.lua',
['graphql.execute'] = 'graphql/execute.lua',
['graphql.util'] = 'graphql/util.lua'
['graphql.validate_variables'] = 'graphql/validate_variables.lua',
}
}
1 change: 0 additions & 1 deletion graphql.lua

This file was deleted.

Loading