forked from tarantool/luagraphqlparser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
736 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
CMakeFiles/ | ||
obj-*/ | ||
CMakeCache.txt | ||
Makefile | ||
cmake_*.cmake | ||
install_manifest.txt | ||
*.a | ||
*.cbp | ||
*.d | ||
*.dylib | ||
*.gcno | ||
*.gcda | ||
*.user | ||
*.o | ||
*.reject | ||
*.so | ||
*.snap* | ||
*.xlog* | ||
*~ | ||
.gdb_history | ||
./build | ||
/build | ||
VERSION | ||
CTestTestfile.cmake | ||
Testing | ||
cmake-build-debug/ | ||
build.luarocks/ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "libgraphqlparser"] | ||
path = libgraphqlparser | ||
url = https://github.com/graphql/libgraphqlparser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
cmake_minimum_required(VERSION 2.8 FATAL_ERROR) | ||
|
||
project(luagraphqlparser C CXX) | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE RelWithDebInfo) | ||
endif() | ||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" ${CMAKE_MODULE_PATH}) | ||
|
||
# Find Tarantool and Lua dependencies | ||
set(TARANTOOL_FIND_REQUIRED ON) | ||
find_package(Tarantool) | ||
include_directories(${TARANTOOL_INCLUDE_DIRS}) | ||
|
||
# Find other dependencies | ||
|
||
add_subdirectory(libgraphqlparser EXCLUDE_FROM_ALL) | ||
include_directories("${CMAKE_SOURCE_DIR}/libgraphqlparser" "${CMAKE_BINARY_DIR}/libgraphqlparser") | ||
|
||
# Set CFLAGS | ||
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") | ||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra -Werror") | ||
# Set CXXFLAGS | ||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Werror") | ||
|
||
# Build module | ||
add_subdirectory(luagraphqlparser) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Define GNU standard installation directories | ||
include(GNUInstallDirs) | ||
|
||
macro(extract_definition name output input) | ||
string(REGEX MATCH "#define[\t ]+${name}[\t ]+\"([^\"]*)\"" | ||
_t "${input}") | ||
string(REGEX REPLACE "#define[\t ]+${name}[\t ]+\"(.*)\"" "\\1" | ||
${output} "${_t}") | ||
endmacro() | ||
|
||
find_path(TARANTOOL_INCLUDE_DIR tarantool/module.h | ||
HINTS ${TARANTOOL_DIR} ENV TARANTOOL_DIR | ||
PATH_SUFFIXES include | ||
) | ||
|
||
if(TARANTOOL_INCLUDE_DIR) | ||
set(_config "-") | ||
file(READ "${TARANTOOL_INCLUDE_DIR}/tarantool/module.h" _config0) | ||
string(REPLACE "\\" "\\\\" _config ${_config0}) | ||
unset(_config0) | ||
extract_definition(PACKAGE_VERSION TARANTOOL_VERSION ${_config}) | ||
extract_definition(INSTALL_PREFIX _install_prefix ${_config}) | ||
unset(_config) | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(TARANTOOL | ||
REQUIRED_VARS TARANTOOL_INCLUDE_DIR VERSION_VAR TARANTOOL_VERSION) | ||
if(TARANTOOL_FOUND) | ||
set(TARANTOOL_INCLUDE_DIRS "${TARANTOOL_INCLUDE_DIR}" | ||
"${TARANTOOL_INCLUDE_DIR}/tarantool/" | ||
CACHE PATH "Include directories for Tarantool") | ||
set(TARANTOOL_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/tarantool" | ||
CACHE PATH "Directory for storing Lua modules written in Lua") | ||
set(TARANTOOL_INSTALL_LUADIR "${CMAKE_INSTALL_DATADIR}/tarantool" | ||
CACHE PATH "Directory for storing Lua modules written in C") | ||
|
||
if (NOT TARANTOOL_FIND_QUIETLY AND NOT FIND_TARANTOOL_DETAILS) | ||
set(FIND_TARANTOOL_DETAILS ON CACHE INTERNAL "Details about TARANTOOL") | ||
message(STATUS "Tarantool LUADIR is ${TARANTOOL_INSTALL_LUADIR}") | ||
message(STATUS "Tarantool LIBDIR is ${TARANTOOL_INSTALL_LIBDIR}") | ||
endif () | ||
endif() | ||
mark_as_advanced(TARANTOOL_INCLUDE_DIRS TARANTOOL_INSTALL_LIBDIR | ||
TARANTOOL_INSTALL_LUADIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
### Luagraphqlparser | ||
|
||
Lua-binding of [libgraphqlparser](https://github.com/graphql/libgraphqlparser) | ||
compatible with [graphql-lua](https://github.com/bjornbytes/graphql-lua). | ||
|
||
Differences from graphql-lua parser: | ||
* Improved error messages | ||
* Null support | ||
|
||
Usage: | ||
```lua | ||
parse = require('luagraphqlparser').parse | ||
parse([[ | ||
query HeroComparison($first: Int = 3) { | ||
leftComparison: hero(episode: EMPIRE) { | ||
...comparisonFields | ||
} | ||
rightComparison: hero(episode: JEDI) { | ||
...comparisonFields | ||
} | ||
} | ||
fragment comparisonFields on Character { | ||
name | ||
friendsConnection(first: $first) { | ||
totalCount | ||
edges { | ||
node { | ||
name | ||
} | ||
} | ||
} | ||
} | ||
]]) | ||
--- | ||
- definitions: | ||
- operation: query | ||
kind: operation | ||
variableDefinitions: | ||
- type: | ||
name: | ||
kind: name | ||
value: Int | ||
kind: namedType | ||
kind: variableDefinition | ||
variable: | ||
name: | ||
kind: name | ||
value: first | ||
kind: variable | ||
defaultValue: | ||
kind: int | ||
value: '3' | ||
name: | ||
kind: name | ||
value: HeroComparison | ||
selectionSet: | ||
selections: | ||
- selectionSet: | ||
selections: | ||
- name: | ||
kind: name | ||
value: comparisonFields | ||
kind: fragmentSpread | ||
kind: selectionSet | ||
kind: field | ||
alias: | ||
name: | ||
kind: name | ||
value: leftComparison | ||
kind: alias | ||
name: | ||
kind: name | ||
value: hero | ||
arguments: | ||
- kind: argument | ||
name: | ||
kind: name | ||
value: episode | ||
value: | ||
kind: enum | ||
value: EMPIRE | ||
- selectionSet: | ||
selections: | ||
- name: | ||
kind: name | ||
value: comparisonFields | ||
kind: fragmentSpread | ||
kind: selectionSet | ||
kind: field | ||
alias: | ||
name: | ||
kind: name | ||
value: rightComparison | ||
kind: alias | ||
name: | ||
kind: name | ||
value: hero | ||
arguments: | ||
- kind: argument | ||
name: | ||
kind: name | ||
value: episode | ||
value: | ||
kind: enum | ||
value: JEDI | ||
kind: selectionSet | ||
- typeCondition: | ||
name: | ||
kind: name | ||
value: Character | ||
kind: namedType | ||
selectionSet: | ||
selections: | ||
- name: | ||
kind: name | ||
value: name | ||
kind: field | ||
- selectionSet: | ||
selections: | ||
- name: | ||
kind: name | ||
value: totalCount | ||
kind: field | ||
- selectionSet: | ||
selections: | ||
- selectionSet: | ||
selections: | ||
- name: | ||
kind: name | ||
value: name | ||
kind: field | ||
kind: selectionSet | ||
name: | ||
kind: name | ||
value: node | ||
kind: field | ||
kind: selectionSet | ||
name: | ||
kind: name | ||
value: edges | ||
kind: field | ||
kind: selectionSet | ||
arguments: | ||
- kind: argument | ||
name: | ||
kind: name | ||
value: first | ||
value: | ||
name: | ||
kind: name | ||
value: first | ||
kind: variable | ||
name: | ||
kind: name | ||
value: friendsConnection | ||
kind: field | ||
kind: selectionSet | ||
name: | ||
kind: name | ||
value: comparisonFields | ||
kind: fragmentDefinition | ||
kind: document | ||
... | ||
``` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Submodule libgraphqlparser
added at
f8928a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
-- name of the package to be published | ||
package = 'luagraphqlparser' | ||
|
||
-- version of the package; it's mandatory, but we don't use it in Tarantool; | ||
-- instead, provide below a specific branch in the package's repository at | ||
-- GitHub and set version to some stub value, e.g. 'scm-1' | ||
version = 'scm-1' | ||
|
||
-- url and branch of the package's repository at GitHub | ||
source = { | ||
url = 'git://github.com/olegrok/luagraphqlparser.git'; | ||
branch = 'master'; | ||
} | ||
|
||
-- general information about the package; | ||
-- for a Tarantool package, we require three fields (summary, homepage, license) | ||
-- and more package information is always welcome | ||
description = { | ||
summary = "Lua graphql parser"; | ||
detailed = [[ | ||
Lua port of libgraphqlparser | ||
]]; | ||
homepage = 'https://github.com/olegrok/luagraphqlparser.git'; | ||
maintainer = "Oleg Babin <[email protected]>"; | ||
license = 'BSD2'; | ||
} | ||
|
||
-- Lua version and other packages on which this one depends; | ||
-- Tarantool currently supports strictly Lua 5.1 | ||
dependencies = { | ||
'lua == 5.1'; | ||
} | ||
|
||
-- build options and paths for the package; | ||
-- this package distributes modules in C, so the build type = 'cmake'; | ||
-- also, specify here all variables required for build: | ||
-- CMAKE_BUILD_TYPE = Tarantool build type (default is RelWithDebInfo) | ||
-- TARANTOOL_INSTALL_LIBDIR = path to all C header files within the package, | ||
-- TARANTOOL_INSTALL_LUADIR = path to all Lua source files within the package | ||
build = { | ||
type = 'cmake'; | ||
variables = { | ||
CMAKE_BUILD_TYPE="RelWithDebInfo"; | ||
TARANTOOL_DIR="$(TARANTOOL_DIR)"; | ||
TARANTOOL_INSTALL_LIBDIR="$(LIBDIR)"; | ||
TARANTOOL_INSTALL_LUADIR="$(LUADIR)"; | ||
}; | ||
} | ||
-- vim: syntax=lua ts=4 sts=4 sw=4 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
if (APPLE) | ||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined suppress -flat_namespace") | ||
endif(APPLE) | ||
|
||
# Add C library | ||
add_library(luagraphqlparser SHARED lib.c) | ||
add_dependencies(luagraphqlparser graphqlparser) | ||
target_link_libraries(luagraphqlparser graphqlparser) | ||
set_target_properties(luagraphqlparser PROPERTIES PREFIX "" OUTPUT_NAME "lib") | ||
|
||
# Install module | ||
install(TARGETS luagraphqlparser LIBRARY DESTINATION ${TARANTOOL_INSTALL_LIBDIR}/${PROJECT_NAME}/) | ||
install(FILES init.lua DESTINATION ${TARANTOOL_INSTALL_LUADIR}/${PROJECT_NAME}/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
return require('luagraphqlparser.lib') |
Oops, something went wrong.