
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
graphqlparser
Advanced tools
Python2.7+ Python3.4+ class-based bindings to libgraphqlparser; just a thin layer on top of libgraphqlparser C API.
Still EXPERIMENTAL
First install libgraphqlparser following instructions on libgraphqlparser github page_ .
Next you can install graphqlparser. The easiest way is using precompiled wheels which are usually available
on graphqlparser github releases_
Pick the right wheel for your platform and python version, then install it using pip::
As an alternative you can install graphqlparser from source distribution:
Install cython
Set an env var $GRAPHQL_HOME to the folder where libgraphqlparser.so and Ast.h are
Install graphqlparser with pip::
LDFLAGS="-L$GRAPHQL_HOME" CFLAGS="-I$GRAPHQL_HOME/c -I$GRAPHQL_HOME" pip install graphqlparser
Make sure libgraphqlparser is available to the loader. You can add its base dir to LD_LIBRARY_PATH.
Then you can start parsing by creating your custom visitor class:
.. code-block:: python
from graphql_parser import GraphQLAstVisitor
class MyVisitor(GraphQLAstVisitor.GraphQLAstVisitor):
def visit_field(self, node):
print('start field %s visit' % node)
# Return 1 to keep visiting children, 0 to skip them
return 1
def end_visit_field(self, node):
print('end field %s visit' % node)
And using it to visit a parsed query:
.. code-block:: python
from graphql_parser import GraphQLParser
query = '{query{}}' node = GraphQLParser.graphql_parse_string(query) MyVisitor().visit_node(node)
See also examples folder.
Rebuild the generated cython files from the libgraphql AST (usually not needed)
download submodules with git checkout --recursive
build libgraphql library in folder ./libgraphqlparser (python2.7 required for building)
(usually pushd libgraphqlparser && cmake . && make && popd works)
generate source code with python ast/build_ast.py
you can now switch to python 3
install cython
run::
LDFLAGS="-L./libgraphqlparser" CFLAGS="-Ilibgraphqlparser/c -Ilibgraphqlparser" python setup.py build_ext
To create a wheel distribution:
pip install wheelmkdir .wheelhousepip wheel --wheel-dir=.wheelhouse ... _libgraphqlparser github page: https://github.com/graphql/libgraphqlparser .. _graphqlparser github releases: https://github.com/elastic-coders/py-graphqlparser/releases/
FAQs
Python bindings for libgraphqlparser (Cython-based)
We found that graphqlparser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.