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

bjorn 0f494589a0 More tests; пре 9 година
tests 0f494589a0 More tests; пре 9 година
README.md a62c0048c8 Update README; пре 9 година
parse.lua 8171413a8d Alias bugfix; пре 9 година
rules.lua 5f5054b13a Finish field validation rules; пре 9 година
schema.lua cc18c785f1 rm print; пре 9 година
types.lua 526e8c0ad4 InputObject type; пре 9 година
validate.lua b0b82bd5d3 Make validate not suck; Add rules; пре 9 година

README.md

GraphQL Lua

Lua implementation of GraphQL parser using LPeg. Experimental.

Example

require 'parse' [[{
  me {
    firstName
    lastName
  }
}]]

Gives you this scary table:

{
  kind = "document",
  definitions = {
    {
      kind = "operation",
      operation = "query",
      selectionSet = {
        kind = "selectionSet",
        selections = {
          {
            kind = "field",
            name = {
              kind = "name",
              value = "me"
            },
            selectionSet = {
              kind = "selectionSet",
              selections = {
                {
                  kind = "field",
                  name = {
                    kind = "name",
                    value = "firstName"
                  }
                },
                {
                  kind = "field",
                  name = {
                    kind = "name",
                    value = "lastName"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Status

The parser can parse virtually all of the query syntax:

  • Documents
  • Definitions
    • OperationDefinition
    • FragmentDefinition
  • Selections
  • Fields
  • Aliases
  • Arguments
  • FragmentSpreads and InlineFragments
  • All value types (scalars, enums, lists, objects, variables).
  • VariableDefinitions (typed)
  • Directives

The type system supports scalars, objects, enums, input objects, interfaces, and unions. The built in scalars are also provided (ints, floats, strings, etc.), as well as the two wrapper types (non null and list).

License

MIT