Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
gql-query-builder-with-pyproject
Advanced tools
This is a GraphQL query builder. This is a fork with pyproject to make installing easier
This is a GraphQL query builder.
Use with method chain.
pip install gql-query-builder
from gql_query_builder import GqlQuery
query = GqlQuery().fields(['name']).query('hero').operation().generate()
print(query)
"""
query {
hero {
name
}
}
"""
from gql_query_builder import GqlQuery
query = GqlQuery().fields(['stars', 'commentary']).query('createReview', input={"episode": "$ep", "review": "$review"}).operation('mutation', name='CreateReviewForEpisode', input={"$ep": "Episode!", "$review": "ReviewInput!"}).generate()
print(query)
"""
mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) {
createReview(episode: $ep, review: $review) {
stars
commentary
}
}
"""
fields()
#Syntax
fields(
fields: List[str] = [],
name: str = '',
condition_expression: str = ''
)
query()
#Syntax
query(
name: str = '',
alias: str = '',
input: Dict[str, Union[str, int]] = {}
)
operation()
#Syntax
operation(
query_type: str = 'query',
name: str = '',
input: Dict[str, Union[str, int]] = {},
queries: List[str] = []
)
fragment()
#Syntax
fragment(
name: str,
interface: str
)
generate()
#Syntax
generate()
from gql_query_builder import GqlQuery
field_friends = GqlQuery().fields(['name'], name='friends').generate()
query = GqlQuery().fields(['name', field_friends]).query('hero').operation('query').generate()
print(query)
"""
query {
hero {
name
friends {
name
}
}
}
"""
from gql_query_builder import GqlQuery
query = GqlQuery().fields(['name', 'height']).query('human', input={"id": '"1000"'}).operation().generate()
print(query)
"""
query {
human(id: "1000") {
name
height
}
}
"""
from gql_query_builder import GqlQuery
GqlQuery().fields(['name', 'height']).query('human', input={"input": {"data": {"id": "1000", "name": "test"}}}).operation().generate()
"""
query{
human(input: {data: {id: "1000", name: "test"}}){
human{
name,
height
}
}
}
"""
from gql_query_builder import GqlQuery
query = GqlQuery().fields(['name', 'height(unit: FOOT)']).query('human', input={"id": '"1000"'}).operation().generate()
print(query)
"""
query {
human(id: "1000") {
name
height(unit: FOOT)
}
}
"""
from gql_query_builder import GqlQuery
query_empirehero = GqlQuery().fields(['name']).query('hero', alias='empireHero', input={"episode": 'EMPIRE'}).generate()
query_jedihero = GqlQuery().fields(['name']).query('hero', alias='jediHero', input={"episode": 'JEDI'}).generate()
query = GqlQuery().operation('query', queries=[query_empirehero, query_jedihero]).generate()
print(query)
"""
query {
empireHero: hero(episode: EMPIRE) {
name
}
jediHero: hero(episode: JEDI) {
name
}
}
"""
from gql_query_builder import GqlQuery
field_friends = GqlQuery().fields(['name'], name='friends').generate()
query = GqlQuery().fields(['name', 'appearsIn', field_friends]).fragment('comparisonFields', 'Character').generate()
print(query)
"""
fragment comparisonFields on Character {
name
appearsIn
friends {
name
}
}
"""
from gql_query_builder import GqlQuery
query_leftComparison = GqlQuery().fields(['...comparisonFields']).query('hero', alias='leftComparison', input={"episode": "EMPIRE"}).generate()
query_rightComparison = GqlQuery().fields(['...comparisonFields']).query('hero', alias='rightComparison', input={"episode": "JEDI"}).generate()
query = GqlQuery().operation('query', queries=[query_leftComparison, query_rightComparison]).generate()
print(query)
"""
query {
leftComparison: hero(episode: EMPIRE) {
...comparisonFields
}
rightComparison: hero(episode: JEDI) {
...comparisonFields
}
}
"""
from gql_query_builder import GqlQuery
field_friends = GqlQuery().fields(['name'], name='friends').generate()
query = GqlQuery().fields(['name', field_friends]).query('hero', input={"episode": "$episode"}).operation('query', name='HeroNameAndFriends', input={"$episode": "Episode"}).generate()
print(query)
"""
query HeroNameAndFriends($episode: Episode) {
hero(episode: $episode) {
name
friends {
name
}
}
}
"""
from gql_query_builder import GqlQuery
field_friends = GqlQuery().fields(['name'], name='friends @include(if: $withFriends)').generate()
query = GqlQuery().fields(['name', field_friends]).query('hero', input={"episode": "$episode"}).operation('query', name='Hero', input={"$episode": "Episode", "$withFriends": "Boolean!"}).generate()
print(query)
"""
query Hero($episode: Episode, $withFriends: Boolean!) {
hero(episode: $episode) {
name
friends @include(if: $withFriends) {
name
}
}
}
"""
FAQs
This is a GraphQL query builder. This is a fork with pyproject to make installing easier
We found that gql-query-builder-with-pyproject 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.