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

bjorn 0f50131800 More fragment validation rules; 9 лет назад
tests 0f494589a0 More tests; 9 лет назад
README.md a62c0048c8 Update README; 9 лет назад
parse.lua c710e58479 argumentsOfCorrectType; 9 лет назад
rules.lua 0f50131800 More fragment validation rules; 9 лет назад
schema.lua 45879a535d Fragment validation rules; 9 лет назад
types.lua 526e8c0ad4 InputObject type; 9 лет назад
validate.lua 0f50131800 More fragment validation 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