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

bjorn 2ae5312cb9 Update README; 9 年之前
README.md 2ae5312cb9 Update README; 9 年之前
parse.lua 072164661e Variables; Types; Directives; 9 年之前

README.md

GraphQL Lua

Lua implementation of GraphQL parser using LPeg. Experimental.

Right now it can parse pretty much all of the query syntax:

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

Missing features:

  • Validation, error handling
  • Comments
  • Type definitions, interfaces, etc.
  • Introspection
  • Execution
  • Unicode stuff

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"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

License

MIT