mirror of
https://github.com/openappsec/openappsec.git
synced 2025-09-30 03:34:26 +03:00
Feb 15th 2023 update
This commit is contained in:
1
external/graphqlparser/python/.gitignore
vendored
Normal file
1
external/graphqlparser/python/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.pyc
|
14
external/graphqlparser/python/CMakeLists.txt
vendored
Normal file
14
external/graphqlparser/python/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
IF (CTYPESGEN_FOUND)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT GraphQLParser.py
|
||||
COMMAND ctypesgen.py ${CMAKE_CURRENT_SOURCE_DIR}/../c/*.h ${CMAKE_CURRENT_BINARY_DIR}/../c/*.h -o ${CMAKE_CURRENT_SOURCE_DIR}/GraphQLParser.py -I ${CMAKE_CURRENT_SOURCE_DIR}/.. -I ${CMAKE_CURRENT_BINARY_DIR}/.. -l graphqlparser -L ${CMAKE_CURRENT_BINARY_DIR}/.. 2>&1 > /dev/null
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/../c/GraphQLAstForEachConcreteType.h ${CMAKE_CURRENT_BINARY_DIR}/../c/GraphQLAst.h ${CMAKE_CURRENT_SOURCE_DIR}/../c/GraphQLAstNode.h ${CMAKE_CURRENT_SOURCE_DIR}/../c/GraphQLAstVisitor.h ${CMAKE_CURRENT_SOURCE_DIR}/../c/GraphQLParser.h
|
||||
)
|
||||
ADD_CUSTOM_TARGET(
|
||||
graphql-parser-python
|
||||
ALL
|
||||
DEPENDS GraphQLParser.py)
|
||||
ELSE()
|
||||
MESSAGE(WARNING "ctypesgen.py not found; install with pip or easy_install if you want to run pythontest.py.")
|
||||
ENDIF()
|
5
external/graphqlparser/python/README.md
vendored
Normal file
5
external/graphqlparser/python/README.md
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
This directory contains an example Python binding to the GraphQL
|
||||
parser and AST library. It uses
|
||||
[ctypesgen.py](https://github.com/davidjamesca/ctypesgen) to generate
|
||||
the binding code automatically from the pure C API in
|
||||
`../c`. `example.py` is a short program that uses this binding.
|
31
external/graphqlparser/python/example.py
vendored
Executable file
31
external/graphqlparser/python/example.py
vendored
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright 2019-present, GraphQL Foundation
|
||||
#
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
from ctypes import *
|
||||
from GraphQLParser import *
|
||||
|
||||
def print_field(field, unused):
|
||||
field_name = GraphQLAstField_get_name(field)
|
||||
field_name_value = GraphQLAstName_get_value(field_name)
|
||||
print 'field : ' + field_name_value
|
||||
return 0
|
||||
|
||||
def main():
|
||||
error = POINTER(c_char)()
|
||||
ast = graphql_parse_string('query myquery { myfield }', byref(error))
|
||||
field_visitor_callbacks = GraphQLAstVisitorCallbacks(visit_field = visit_field_func(print_field))
|
||||
graphql_node_visit(ast, pointer(field_visitor_callbacks), None)
|
||||
|
||||
graphql_node_free(ast)
|
||||
|
||||
ast = graphql_parse_string('query errorQuery on oops { myfield }', byref(error))
|
||||
print 'Example error:', string_at(error)
|
||||
graphql_error_free(error)
|
||||
if ast:
|
||||
print 'BUG: we should have got a null AST back, but we got:', ast
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Reference in New Issue
Block a user