Skip to content

Commit 2f9b7fb

Browse files
author
Marco Paolini
committed
Usage instructions
1 parent 0b04c9e commit 2f9b7fb

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

README.rst

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,35 @@ Installing from source is a bit more complex. The main steps are
2828
LDFLAGS="-L$GRAPHQL_HOME" CFLAGS="-I$GRAPHQL_HOME/c -I$GRAPHQL_HOME" pip install graphqlparser
2929

3030

31+
Usage
32+
-----
33+
34+
Make sure ``libgraphqlparser`` is available to the loader. You can add its base dir to ``LD_LIBRARY_PATH``.
35+
36+
Then you can start parsing by creating your custom visitor class::
37+
38+
from graphql_parser import GraphQLAstVisitor
39+
40+
class MyVisitor(GraphQLAstVisitor.GraphQLAstVisitor):
41+
42+
def visit_field(self, node):
43+
print('start field %s visit' % node)
44+
45+
def end_visit_field(self, node):
46+
print('end field %s visit' % node)
47+
48+
And using it to visit a parsed query::
49+
50+
from graphql_parser import GraphQLParser
51+
52+
node = GraphQLParser.graphql_parse_string(query)
53+
MyVisitor().visit_node(node)
54+
55+
3156
Building from source checkout
3257
-----------------------------
3358

34-
Needed to rebuild the generate cython files from the libgraphql AST
59+
Rebuild the generated cython files from the libgraphql AST (usually not needed)
3560

3661
- download submodules with ``git checkout --recursive``
3762
- build libgraphql library in folder ``./libgraphqlparser`` (python2.7 required for building)
@@ -51,12 +76,6 @@ To create a wheel distribution:
5176
- build with ``pip wheel --wheel-dir=.wheelhouse .``
5277

5378

54-
Run
55-
---
56-
57-
Make sure ``libgraphqlparser`` is available to the loader. You can add its base dir to ``LD_LIBRARY_PATH``.
58-
59-
6079
Known issues
6180
------------
6281

0 commit comments

Comments
 (0)