GraphQL implementation in Lua
#lua #graphql #server #library
|
há 9 anos atrás | |
---|---|---|
graphql | há 9 anos atrás | |
tests | há 9 anos atrás | |
LICENSE | há 9 anos atrás | |
README.md | há 9 anos atrás | |
graphql-0.0.1-1.rockspec | há 9 anos atrás | |
graphql.lua | há 9 anos atrás |
Lua implementation of GraphQL parser using LPeg.
Parsing queries:
local parse = require 'graphql.parse'
local ast = parse [[
query getUser {
firstName
lastName
}
]]
Creating schemas:
local schema = require 'graphql.schema'
local types = require 'graphql.types'
local person = types.object {
name = 'Person',
fields = {
firstName = types.string.nonNull
lastName = types.string.nonNull
}
}
local schema = schema.create {
query = types.object {
name = 'Query',
fields = {
person = person
}
}
}
Validating schemas:
local validate = require 'graphql.validate'
validate(schema, ast)
Executing queries:
local execute = require 'graphql.execute'
local rootValue = {}
local variables = {
foo = 'bar'
}
local operationName = 'myOperation'
execute(schema, ast, rootValue, variables, operationName)
lua tests/runner.lua
MIT