summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-05-10 06:06:20 +0000
committerCoprDistGit <infra@openeuler.org>2023-05-10 06:06:20 +0000
commit05c7f3719956a2ce209be342c9831b58022ce21f (patch)
tree073c0b500b6bd0435651f636f105aa855bf1f5fb
parent4f1f8cd61ff8d805f3ca027b3d5f0cee523be858 (diff)
automatic import of python-gql-query-builder
-rw-r--r--.gitignore1
-rw-r--r--python-gql-query-builder.spec921
-rw-r--r--sources1
3 files changed, 923 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..90fe741 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/gql-query-builder-0.1.7.tar.gz
diff --git a/python-gql-query-builder.spec b/python-gql-query-builder.spec
new file mode 100644
index 0000000..db6ee76
--- /dev/null
+++ b/python-gql-query-builder.spec
@@ -0,0 +1,921 @@
+%global _empty_manifest_terminate_build 0
+Name: python-gql-query-builder
+Version: 0.1.7
+Release: 1
+Summary: This is a GraphQL query builder.
+License: MIT License
+URL: https://github.com/youyo/gql-query-builder
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/62/bd/68d07678108ae2038dfd98ed4fdfcde833a2c015af27ef23c2a30020b406/gql-query-builder-0.1.7.tar.gz
+BuildArch: noarch
+
+
+%description
+# gql-query-builder
+
+![](https://github.com/youyo/gql-query-builder/workflows/Publish%20python%20package/badge.svg)
+
+This is a GraphQL query builder.
+Use with method chain.
+
+## Install
+
+```
+pip install gql-query-builder
+```
+
+## Usage
+
+- query
+
+```python
+from gql_query_builder import GqlQuery
+
+query = GqlQuery().fields(['name']).query('hero').operation().generate()
+print(query)
+"""
+query {
+ hero {
+ name
+ }
+}
+"""
+```
+
+- mutation
+
+```python
+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
+ }
+}
+"""
+```
+
+### Methods
+
+- `fields()`
+ build response fields.
+
+```python
+#Syntax
+
+fields(
+ fields: List[str] = [],
+ name: str = '',
+ condition_expression: str = ''
+)
+```
+
+- `query()`
+ build query fields.
+
+```python
+#Syntax
+
+query(
+ name: str = '',
+ alias: str = '',
+ input: Dict[str, Union[str, int]] = {}
+)
+```
+
+- `operation()`
+ build operation fields.
+
+```python
+#Syntax
+
+operation(
+ query_type: str = 'query',
+ name: str = '',
+ input: Dict[str, Union[str, int]] = {},
+ queries: List[str] = []
+)
+```
+
+- `fragment()`
+ build fragment fields.
+
+```python
+#Syntax
+
+fragment(
+ name: str,
+ interface: str
+)
+```
+
+- `generate()`
+ generate query.
+
+```python
+#Syntax
+
+generate()
+```
+
+## Examples
+
+- Nesting fields
+
+```python
+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
+ }
+ }
+}
+"""
+```
+
+- Query with input
+
+```python
+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
+ }
+}
+"""
+```
+
+- Query with nested input
+
+```python
+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
+ }
+ }
+}
+"""
+```
+
+- Query with input and arguments
+
+```python
+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)
+ }
+}
+"""
+```
+
+- Alias
+
+```python
+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
+ }
+}
+"""
+```
+
+- Fragments
+
+```python
+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
+ }
+}
+"""
+```
+
+- Refer to fragments
+
+```python
+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
+ }
+}
+"""
+```
+
+- Query with variables
+
+```python
+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
+ }
+ }
+}
+"""
+```
+
+- Directives
+
+```python
+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
+ }
+ }
+}
+"""
+```
+
+%package -n python3-gql-query-builder
+Summary: This is a GraphQL query builder.
+Provides: python-gql-query-builder
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-gql-query-builder
+# gql-query-builder
+
+![](https://github.com/youyo/gql-query-builder/workflows/Publish%20python%20package/badge.svg)
+
+This is a GraphQL query builder.
+Use with method chain.
+
+## Install
+
+```
+pip install gql-query-builder
+```
+
+## Usage
+
+- query
+
+```python
+from gql_query_builder import GqlQuery
+
+query = GqlQuery().fields(['name']).query('hero').operation().generate()
+print(query)
+"""
+query {
+ hero {
+ name
+ }
+}
+"""
+```
+
+- mutation
+
+```python
+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
+ }
+}
+"""
+```
+
+### Methods
+
+- `fields()`
+ build response fields.
+
+```python
+#Syntax
+
+fields(
+ fields: List[str] = [],
+ name: str = '',
+ condition_expression: str = ''
+)
+```
+
+- `query()`
+ build query fields.
+
+```python
+#Syntax
+
+query(
+ name: str = '',
+ alias: str = '',
+ input: Dict[str, Union[str, int]] = {}
+)
+```
+
+- `operation()`
+ build operation fields.
+
+```python
+#Syntax
+
+operation(
+ query_type: str = 'query',
+ name: str = '',
+ input: Dict[str, Union[str, int]] = {},
+ queries: List[str] = []
+)
+```
+
+- `fragment()`
+ build fragment fields.
+
+```python
+#Syntax
+
+fragment(
+ name: str,
+ interface: str
+)
+```
+
+- `generate()`
+ generate query.
+
+```python
+#Syntax
+
+generate()
+```
+
+## Examples
+
+- Nesting fields
+
+```python
+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
+ }
+ }
+}
+"""
+```
+
+- Query with input
+
+```python
+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
+ }
+}
+"""
+```
+
+- Query with nested input
+
+```python
+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
+ }
+ }
+}
+"""
+```
+
+- Query with input and arguments
+
+```python
+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)
+ }
+}
+"""
+```
+
+- Alias
+
+```python
+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
+ }
+}
+"""
+```
+
+- Fragments
+
+```python
+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
+ }
+}
+"""
+```
+
+- Refer to fragments
+
+```python
+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
+ }
+}
+"""
+```
+
+- Query with variables
+
+```python
+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
+ }
+ }
+}
+"""
+```
+
+- Directives
+
+```python
+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
+ }
+ }
+}
+"""
+```
+
+%package help
+Summary: Development documents and examples for gql-query-builder
+Provides: python3-gql-query-builder-doc
+%description help
+# gql-query-builder
+
+![](https://github.com/youyo/gql-query-builder/workflows/Publish%20python%20package/badge.svg)
+
+This is a GraphQL query builder.
+Use with method chain.
+
+## Install
+
+```
+pip install gql-query-builder
+```
+
+## Usage
+
+- query
+
+```python
+from gql_query_builder import GqlQuery
+
+query = GqlQuery().fields(['name']).query('hero').operation().generate()
+print(query)
+"""
+query {
+ hero {
+ name
+ }
+}
+"""
+```
+
+- mutation
+
+```python
+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
+ }
+}
+"""
+```
+
+### Methods
+
+- `fields()`
+ build response fields.
+
+```python
+#Syntax
+
+fields(
+ fields: List[str] = [],
+ name: str = '',
+ condition_expression: str = ''
+)
+```
+
+- `query()`
+ build query fields.
+
+```python
+#Syntax
+
+query(
+ name: str = '',
+ alias: str = '',
+ input: Dict[str, Union[str, int]] = {}
+)
+```
+
+- `operation()`
+ build operation fields.
+
+```python
+#Syntax
+
+operation(
+ query_type: str = 'query',
+ name: str = '',
+ input: Dict[str, Union[str, int]] = {},
+ queries: List[str] = []
+)
+```
+
+- `fragment()`
+ build fragment fields.
+
+```python
+#Syntax
+
+fragment(
+ name: str,
+ interface: str
+)
+```
+
+- `generate()`
+ generate query.
+
+```python
+#Syntax
+
+generate()
+```
+
+## Examples
+
+- Nesting fields
+
+```python
+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
+ }
+ }
+}
+"""
+```
+
+- Query with input
+
+```python
+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
+ }
+}
+"""
+```
+
+- Query with nested input
+
+```python
+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
+ }
+ }
+}
+"""
+```
+
+- Query with input and arguments
+
+```python
+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)
+ }
+}
+"""
+```
+
+- Alias
+
+```python
+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
+ }
+}
+"""
+```
+
+- Fragments
+
+```python
+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
+ }
+}
+"""
+```
+
+- Refer to fragments
+
+```python
+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
+ }
+}
+"""
+```
+
+- Query with variables
+
+```python
+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
+ }
+ }
+}
+"""
+```
+
+- Directives
+
+```python
+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
+ }
+ }
+}
+"""
+```
+
+%prep
+%autosetup -n gql-query-builder-0.1.7
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-gql-query-builder -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Wed May 10 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1.7-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..860dc96
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+427f6b03236417e4b5aeacb98edb36fc gql-query-builder-0.1.7.tar.gz