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

bjorn afc95fcaef Variable uses are defined; %!s(int64=9) %!d(string=hai) anos
tests 0f494589a0 More tests; %!s(int64=9) %!d(string=hai) anos
README.md a62c0048c8 Update README; %!s(int64=9) %!d(string=hai) anos
parse.lua 590fa1817a uniqueInputObjectFields; %!s(int64=9) %!d(string=hai) anos
rules.lua afc95fcaef Variable uses are defined; %!s(int64=9) %!d(string=hai) anos
schema.lua af0930639a Variable rules; %!s(int64=9) %!d(string=hai) anos
types.lua 733f1c1aff Directive rules; %!s(int64=9) %!d(string=hai) anos
validate.lua afc95fcaef Variable uses are defined; %!s(int64=9) %!d(string=hai) anos

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