
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Supply Chain Security
Vulnerability
Quality
Maintenance
License
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
A python library to interact with GraphQL APIs with no need of hardcoded strings.
This library acts as a mapper between python and GraphQL languages for GraphQL clients, allowing a code-first approach when calling a GraphQL API server. It translates GraphQL entities into python objects and viceversa in order to avoid working with massive "copy&paste"s.
This document contains a quick overview of the functionalities, for more details and options you can read here:
The package does not use any third-party libraries, it relies only on python 3 (3.10+) standard libraries.
Available in PyPI, the following command will install the library:
pip install py-graphql-mapper
To generate the code execute the following command:
pgmcodegen generate ./pathToOutputFolder -apiArgs ./<pathToArgsFile>/generatorArgs.json
This command requires a json file containing the parameters needed to get the GraphQL schema
A sample is available in the main folder 'cli_args.json'.
The following python files will be generated:
These links show code generated using the library Github GraphQL API, Rapid GraphQL API and GeoDBCities API
More command options are available here
Choose the query class you want to use from the generated file queries.py (or a mutation from mutations.py):
Instantiate it adding GraphQL arguments if needed:
from .output.gdbc.queries import currencies
my_currencies = currencies(last=7, before='MTE=')
or add them using the field args
my_currencies._args.last = 7
my_currencies._args.before = 'MTE='
Then call export_gql_source property to pass the payload to the HTTP request:
(example using requests library)
import requests
response = requests.request('POST', url='https://geodb-cities-graphql.p.rapidapi.com/',
json= { "query": my_currencies.export_gql_source },
headers={
"content-type": "application/json",
"X-RapidAPI-Key": '123402mmri02fni230iif32jr420',
"X-RapidAPI-Host": "geodb-cities-graphql.p.rapidapi.com"
}
)
More details on how to set a query here
Obtained the response from the GraphQL API the following code will map the received json payload into the python object
from pygqlmap.network import GQLResponse
gqlResponse = GQLResponse(response)
gqlResponse.map_gqldata_to_obj(myCurrenciesQuery.type)
print('Result object: ' + str(gqlResponse.result_obj))
The mapped response from the GraphQL server will be available within gqlResponse object: _gqlResponse.result_obj_
More details here
A suite of use cases here
FAQs
A python library to call GraphQL APIs without using hardcoded strings
We found that py-graphql-mapper 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.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.