GraphQL implementation in Lua
#lua #graphql #server #library

bjorn 8b3940a8bd Update README; há 9 anos atrás
graphql 65f3c1645a Modify package.lua for lit; há 9 anos atrás
tests 7b81a16924 More tests; Bugfixes; há 9 anos atrás
LICENSE 4c06a53634 Add LICENSE; há 9 anos atrás
README.md 8b3940a8bd Update README; há 9 anos atrás
graphql-0.0.1-1.rockspec f8a8edd24d Add rockspec; há 9 anos atrás
graphql.lua 5e5d9dfcad Restructure source; há 9 anos atrás

README.md

GraphQL Lua

Lua implementation of GraphQL parser using LPeg.

API

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)

Running tests

lua tests/runner.lua

License

MIT