Browse Source

Add README example;

bjorn 9 years ago
parent
commit
0b4bbf588c
1 changed files with 59 additions and 0 deletions
  1. 59 0
      README.md

+ 59 - 0
README.md

@@ -3,6 +3,65 @@ GraphQL Lua
 
 Lua implementation of GraphQL parser using LPeg.  Experimental.
 
+Example
+---
+
+```lua
+require 'parse' [[
+{
+  me {
+		firstName
+    lastName
+  }
+}
+]]
+```
+
+Gives you a table that looks like this:
+
+```lua
+{
+  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
 ---