sgqlc 16.3__tar.gz → 16.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sgqlc-16.3 → sgqlc-16.4}/PKG-INFO +5 -5
- {sgqlc-16.3 → sgqlc-16.4}/README.rst +1 -1
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/conf.py +2 -2
- {sgqlc-16.3 → sgqlc-16.4}/pyproject.toml +9 -4
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/__init__.py +1 -1
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/codegen/operation.py +12 -1
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/codegen/schema.py +12 -8
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/operation/__init__.py +1 -1
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/types/__init__.py +29 -0
- sgqlc-16.4/tests/test-operation-codegen.py +232 -0
- {sgqlc-16.3 → sgqlc-16.4}/AUTHORS +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/LICENSE +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/_static/.keepme +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/_static/logo-sgqlc.png +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/favicon-sgqlc.png +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/index.rst +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/sgqlc.codegen.rst +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/sgqlc.endpoint.base.rst +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/sgqlc.endpoint.http.rst +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/sgqlc.endpoint.requests.rst +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/sgqlc.endpoint.rst +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/sgqlc.endpoint.websocket.rst +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/sgqlc.introspection.rst +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/sgqlc.operation.rst +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/sgqlc.rst +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/sgqlc.types.datetime.rst +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/sgqlc.types.relay.rst +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/sgqlc.types.rst +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/doc/source/sgqlc.types.uuid.rst +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/codegen/__init__.py +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/codegen/__main__.py +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/endpoint/__init__.py +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/endpoint/base.py +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/endpoint/http.py +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/endpoint/requests.py +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/endpoint/websocket.py +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/introspection/__init__.py +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/introspection/__main__.py +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/types/datetime.py +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/types/relay.py +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/sgqlc/types/uuid.py +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/tests/test-endpoint-http.py +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/tests/test-endpoint-requests.py +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/tests/test-endpoint-websocket.py +0 -0
- {sgqlc-16.3 → sgqlc-16.4}/tests/test-introspection.py +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sgqlc
|
|
3
|
-
Version: 16.
|
|
3
|
+
Version: 16.4
|
|
4
4
|
Summary: Simple GraphQL Client
|
|
5
5
|
Home-page: http://github.com/profusion/sgqlc
|
|
6
6
|
License: ISCL
|
|
7
7
|
Keywords: graphql,client,http,endpoint
|
|
8
8
|
Author: Gustavo Sverzut Barbieri
|
|
9
9
|
Author-email: barbieri@profusion.mobi
|
|
10
|
-
Requires-Python: >=3.
|
|
10
|
+
Requires-Python: >=3.8,<3.13
|
|
11
11
|
Classifier: Development Status :: 4 - Beta
|
|
12
12
|
Classifier: Environment :: Console
|
|
13
13
|
Classifier: Environment :: Web Environment
|
|
@@ -17,15 +17,15 @@ Classifier: License :: Other/Proprietary License
|
|
|
17
17
|
Classifier: Operating System :: OS Independent
|
|
18
18
|
Classifier: Programming Language :: Python
|
|
19
19
|
Classifier: Programming Language :: Python :: 3
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.8
|
|
22
21
|
Classifier: Programming Language :: Python :: 3.9
|
|
23
22
|
Classifier: Programming Language :: Python :: 3.10
|
|
24
23
|
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
25
|
Classifier: Topic :: Utilities
|
|
26
26
|
Provides-Extra: requests
|
|
27
27
|
Provides-Extra: websocket
|
|
28
|
-
Requires-Dist: graphql-core (>=3.
|
|
28
|
+
Requires-Dist: graphql-core (>=3.2.4,<4.0.0)
|
|
29
29
|
Requires-Dist: requests ; extra == "requests"
|
|
30
30
|
Requires-Dist: websocket-client ; extra == "websocket"
|
|
31
31
|
Project-URL: Documentation, https://sgqlc.readthedocs.io/
|
|
@@ -541,7 +541,7 @@ Run the tests (one of the below):
|
|
|
541
541
|
|
|
542
542
|
Keep 100% coverage. You can look at the coverage report at
|
|
543
543
|
``cover/index.html``. To do that, prefer
|
|
544
|
-
`doctest <https://docs.python.org/3.
|
|
544
|
+
`doctest <https://docs.python.org/3.12/library/doctest.html>`_
|
|
545
545
|
so it serves as
|
|
546
546
|
both documentation and test. However we use
|
|
547
547
|
`pytest <https://docs.pytest.org/>`_ to write explicit tests that would be
|
|
@@ -507,7 +507,7 @@ Run the tests (one of the below):
|
|
|
507
507
|
|
|
508
508
|
Keep 100% coverage. You can look at the coverage report at
|
|
509
509
|
``cover/index.html``. To do that, prefer
|
|
510
|
-
`doctest <https://docs.python.org/3.
|
|
510
|
+
`doctest <https://docs.python.org/3.12/library/doctest.html>`_
|
|
511
511
|
so it serves as
|
|
512
512
|
both documentation and test. However we use
|
|
513
513
|
`pytest <https://docs.pytest.org/>`_ to write explicit tests that would be
|
|
@@ -61,9 +61,9 @@ author = 'ProFUSION Sistemas e Solucoes LTDA'
|
|
|
61
61
|
# built documents.
|
|
62
62
|
#
|
|
63
63
|
# The short X.Y version.
|
|
64
|
-
version = '16.
|
|
64
|
+
version = '16.4'
|
|
65
65
|
# The full version, including alpha/beta/rc tags.
|
|
66
|
-
release = '16.
|
|
66
|
+
release = '16.4'
|
|
67
67
|
|
|
68
68
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
|
69
69
|
# for a list of supported languages.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[tool.black]
|
|
2
2
|
line-length = 79
|
|
3
3
|
skip-string-normalization = true
|
|
4
|
-
target-version = ['
|
|
4
|
+
target-version = ['py38', 'py39', 'py310', 'py311', 'py312']
|
|
5
5
|
force-exclude = '/(doc/|examples/.*(schema|operations)[.]py)'
|
|
6
6
|
|
|
7
7
|
[tool.pytest.ini_options]
|
|
@@ -27,7 +27,7 @@ norecursedirs = [
|
|
|
27
27
|
|
|
28
28
|
[tool.poetry]
|
|
29
29
|
name = 'sgqlc'
|
|
30
|
-
version = '16.
|
|
30
|
+
version = '16.4'
|
|
31
31
|
description = 'Simple GraphQL Client'
|
|
32
32
|
readme = 'README.rst'
|
|
33
33
|
authors = [
|
|
@@ -59,8 +59,9 @@ include = [
|
|
|
59
59
|
sgqlc-codegen = 'sgqlc.codegen:main'
|
|
60
60
|
|
|
61
61
|
[tool.poetry.dependencies]
|
|
62
|
-
python
|
|
63
|
-
|
|
62
|
+
# <3.13 is to enable coveralls 4, which requires python >=3.8,<3.13
|
|
63
|
+
python = '>=3.8,<3.13'
|
|
64
|
+
graphql-core = '^3.2.4'
|
|
64
65
|
websocket-client = { version = '*', optional = true }
|
|
65
66
|
requests = { version = '*', optional = true }
|
|
66
67
|
|
|
@@ -75,6 +76,10 @@ pytest-cov = '*'
|
|
|
75
76
|
sphinx = '*'
|
|
76
77
|
sphinx-argparse = '*'
|
|
77
78
|
|
|
79
|
+
[tool.poetry.group.docs.dependencies]
|
|
80
|
+
sphinx = '*'
|
|
81
|
+
sphinx-argparse = '*'
|
|
82
|
+
|
|
78
83
|
[build-system]
|
|
79
84
|
requires = ['poetry-core']
|
|
80
85
|
build-backend = 'poetry.core.masonry.api'
|
|
@@ -149,6 +149,9 @@ class SchemaValidation(NoValidation):
|
|
|
149
149
|
possible_types = typ['possibleTypes'] or typ['interfaces'] or []
|
|
150
150
|
typ['possibleTypes'] = {t['name'] for t in possible_types}
|
|
151
151
|
|
|
152
|
+
interfaces = typ['interfaces'] or []
|
|
153
|
+
typ['interfaces'] = {t['name'] for t in interfaces}
|
|
154
|
+
|
|
152
155
|
return typ
|
|
153
156
|
|
|
154
157
|
def _create_field(self, field):
|
|
@@ -743,7 +746,8 @@ def fragment_%(name)s():
|
|
|
743
746
|
self.type_stack.append(None)
|
|
744
747
|
return
|
|
745
748
|
type_name = node.type_condition.name.value
|
|
746
|
-
|
|
749
|
+
condition_type = self.validation.get_type(type_name)
|
|
750
|
+
if not self._type_valid_in_fragment(condition_type, typ):
|
|
747
751
|
self.report_possible_type_validation(node, typ, type_name)
|
|
748
752
|
|
|
749
753
|
try:
|
|
@@ -752,6 +756,13 @@ def fragment_%(name)s():
|
|
|
752
756
|
except KeyError as ex:
|
|
753
757
|
self.report_type_validation(node, ex)
|
|
754
758
|
|
|
759
|
+
@staticmethod
|
|
760
|
+
def _type_valid_in_fragment(condition_type, fragment_type):
|
|
761
|
+
return (
|
|
762
|
+
fragment_type['name'] in condition_type['interfaces']
|
|
763
|
+
or condition_type['name'] in fragment_type['possibleTypes']
|
|
764
|
+
)
|
|
765
|
+
|
|
755
766
|
def leave_inline_fragment(self, node, *_args):
|
|
756
767
|
self.type_stack.pop()
|
|
757
768
|
return (
|
|
@@ -137,14 +137,18 @@ def graphql_type_to_str(t):
|
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
builtin_types_import = 'sgqlc.types'
|
|
140
|
-
builtin_scalar_imports =
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
datetime_scalar_imports =
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
140
|
+
builtin_scalar_imports = dict.fromkeys(
|
|
141
|
+
('Int', 'Float', 'String', 'Boolean', 'ID'),
|
|
142
|
+
builtin_types_import,
|
|
143
|
+
)
|
|
144
|
+
datetime_scalar_imports = dict.fromkeys(
|
|
145
|
+
('DateTime', 'Date', 'Time'),
|
|
146
|
+
'sgqlc.types.datetime',
|
|
147
|
+
)
|
|
148
|
+
relay_imports = dict.fromkeys(
|
|
149
|
+
('Node', 'PageInfo'),
|
|
150
|
+
'sgqlc.types.relay',
|
|
151
|
+
)
|
|
148
152
|
|
|
149
153
|
default_type_imports = {
|
|
150
154
|
**builtin_scalar_imports,
|
|
@@ -1492,7 +1492,7 @@ number
|
|
|
1492
1492
|
>>> op.repository(id='repo2', __alias__='alias').issues.title()
|
|
1493
1493
|
title
|
|
1494
1494
|
>>> type(op['repository']) # it's the selector, not a selection!
|
|
1495
|
-
<class 'sgqlc.operation.
|
|
1495
|
+
<class 'sgqlc.operation.Selector'>
|
|
1496
1496
|
>>> op['repository'].__selection__() # default selection
|
|
1497
1497
|
repository(id: "repo1") {
|
|
1498
1498
|
issues {
|
|
@@ -126,6 +126,13 @@ See examples:
|
|
|
126
126
|
Examples
|
|
127
127
|
--------
|
|
128
128
|
|
|
129
|
+
Let's start our examples/doctest by restoring the ``gloal_schema`` to the
|
|
130
|
+
original schema after ``sgqlc.types`` was loaded the first time
|
|
131
|
+
(ie: ``pytest`` shares execution, so if ``sgqlc.operation`` was
|
|
132
|
+
loaded before ``sgqlc.types``, we need to restore to the initial snapshot):
|
|
133
|
+
|
|
134
|
+
>>> global_schema.__snapshot_restore__(__types_schema_snapshot__)
|
|
135
|
+
|
|
129
136
|
Common Usage
|
|
130
137
|
~~~~~~~~~~~~
|
|
131
138
|
|
|
@@ -668,6 +675,23 @@ class Schema:
|
|
|
668
675
|
for k, v in base_schema.__kinds.items():
|
|
669
676
|
self.__kinds.setdefault(k, ODict()).update(v)
|
|
670
677
|
|
|
678
|
+
def __snapshot_create__(self):
|
|
679
|
+
state = (
|
|
680
|
+
self.__all,
|
|
681
|
+
self.__kinds,
|
|
682
|
+
self.__cache__,
|
|
683
|
+
)
|
|
684
|
+
import copy
|
|
685
|
+
|
|
686
|
+
return copy.deepcopy(state)
|
|
687
|
+
|
|
688
|
+
def __snapshot_restore__(self, state):
|
|
689
|
+
import copy
|
|
690
|
+
|
|
691
|
+
# yet another copy, so we don't modify the snapshot!
|
|
692
|
+
state = copy.deepcopy(state)
|
|
693
|
+
self.__all, self.__kinds, self.__cache__ = state
|
|
694
|
+
|
|
671
695
|
def __contains__(self, key):
|
|
672
696
|
'''Checks if the type name is known in this schema.
|
|
673
697
|
|
|
@@ -2930,3 +2954,8 @@ map_python_to_graphql = {
|
|
|
2930
2954
|
bool: Boolean,
|
|
2931
2955
|
id: ID,
|
|
2932
2956
|
}
|
|
2957
|
+
|
|
2958
|
+
|
|
2959
|
+
# Save the global schema snapshot, used in doctest and possible by
|
|
2960
|
+
# some external users that need to remove temporary types
|
|
2961
|
+
__types_schema_snapshot__ = global_schema.__snapshot_create__()
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
from io import StringIO
|
|
2
|
+
from graphql import Source
|
|
3
|
+
|
|
4
|
+
from sgqlc.codegen.operation import CodeGen, load_schema, ParsedSchemaName
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
NESTED_INTERFACE_QUERY = """
|
|
8
|
+
query TestQuery {
|
|
9
|
+
foo {
|
|
10
|
+
... on Bar {
|
|
11
|
+
barField
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
NESTED_INTERFACE_SCHEMA = """
|
|
18
|
+
{
|
|
19
|
+
"__schema": {
|
|
20
|
+
"queryType": {
|
|
21
|
+
"name": "Query"
|
|
22
|
+
},
|
|
23
|
+
"mutationType": null,
|
|
24
|
+
"subscriptionType": null,
|
|
25
|
+
"types": [
|
|
26
|
+
{
|
|
27
|
+
"kind": "OBJECT",
|
|
28
|
+
"name": "Query",
|
|
29
|
+
"description": null,
|
|
30
|
+
"fields": [
|
|
31
|
+
{
|
|
32
|
+
"name": "foo",
|
|
33
|
+
"description": null,
|
|
34
|
+
"args": [],
|
|
35
|
+
"type": {
|
|
36
|
+
"kind": "INTERFACE",
|
|
37
|
+
"name": "Foo",
|
|
38
|
+
"ofType": null
|
|
39
|
+
},
|
|
40
|
+
"isDeprecated": false,
|
|
41
|
+
"deprecationReason": null
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"inputFields": null,
|
|
45
|
+
"interfaces": [],
|
|
46
|
+
"enumValues": null,
|
|
47
|
+
"possibleTypes": null
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"kind": "INTERFACE",
|
|
51
|
+
"name": "Foo",
|
|
52
|
+
"description": null,
|
|
53
|
+
"fields": [
|
|
54
|
+
{
|
|
55
|
+
"name": "fooField",
|
|
56
|
+
"description": null,
|
|
57
|
+
"args": [],
|
|
58
|
+
"type": {
|
|
59
|
+
"kind": "NON_NULL",
|
|
60
|
+
"name": null,
|
|
61
|
+
"ofType": {
|
|
62
|
+
"kind": "SCALAR",
|
|
63
|
+
"name": "String",
|
|
64
|
+
"ofType": null
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"isDeprecated": false,
|
|
68
|
+
"deprecationReason": null
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"inputFields": null,
|
|
72
|
+
"interfaces": [],
|
|
73
|
+
"enumValues": null,
|
|
74
|
+
"possibleTypes": [
|
|
75
|
+
{
|
|
76
|
+
"kind": "OBJECT",
|
|
77
|
+
"name": "Baz",
|
|
78
|
+
"ofType": null
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"kind": "SCALAR",
|
|
84
|
+
"name": "String",
|
|
85
|
+
"description": "The `String` scalar type represents textual data",
|
|
86
|
+
"fields": null,
|
|
87
|
+
"inputFields": null,
|
|
88
|
+
"interfaces": null,
|
|
89
|
+
"enumValues": null,
|
|
90
|
+
"possibleTypes": null
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"kind": "INTERFACE",
|
|
94
|
+
"name": "Bar",
|
|
95
|
+
"description": null,
|
|
96
|
+
"fields": [
|
|
97
|
+
{
|
|
98
|
+
"name": "fooField",
|
|
99
|
+
"description": null,
|
|
100
|
+
"args": [],
|
|
101
|
+
"type": {
|
|
102
|
+
"kind": "NON_NULL",
|
|
103
|
+
"name": null,
|
|
104
|
+
"ofType": {
|
|
105
|
+
"kind": "SCALAR",
|
|
106
|
+
"name": "String",
|
|
107
|
+
"ofType": null
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"isDeprecated": false,
|
|
111
|
+
"deprecationReason": null
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "barField",
|
|
115
|
+
"description": null,
|
|
116
|
+
"args": [],
|
|
117
|
+
"type": {
|
|
118
|
+
"kind": "NON_NULL",
|
|
119
|
+
"name": null,
|
|
120
|
+
"ofType": {
|
|
121
|
+
"kind": "SCALAR",
|
|
122
|
+
"name": "String",
|
|
123
|
+
"ofType": null
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"isDeprecated": false,
|
|
127
|
+
"deprecationReason": null
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"inputFields": null,
|
|
131
|
+
"interfaces": [
|
|
132
|
+
{
|
|
133
|
+
"kind": "INTERFACE",
|
|
134
|
+
"name": "Foo",
|
|
135
|
+
"ofType": null
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
"enumValues": null,
|
|
139
|
+
"possibleTypes": [
|
|
140
|
+
{
|
|
141
|
+
"kind": "OBJECT",
|
|
142
|
+
"name": "Baz",
|
|
143
|
+
"ofType": null
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"kind": "OBJECT",
|
|
149
|
+
"name": "Baz",
|
|
150
|
+
"description": null,
|
|
151
|
+
"fields": [
|
|
152
|
+
{
|
|
153
|
+
"name": "barField",
|
|
154
|
+
"description": null,
|
|
155
|
+
"args": [],
|
|
156
|
+
"type": {
|
|
157
|
+
"kind": "NON_NULL",
|
|
158
|
+
"name": null,
|
|
159
|
+
"ofType": {
|
|
160
|
+
"kind": "SCALAR",
|
|
161
|
+
"name": "String",
|
|
162
|
+
"ofType": null
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"isDeprecated": false,
|
|
166
|
+
"deprecationReason": null
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"name": "fooField",
|
|
170
|
+
"description": null,
|
|
171
|
+
"args": [],
|
|
172
|
+
"type": {
|
|
173
|
+
"kind": "NON_NULL",
|
|
174
|
+
"name": null,
|
|
175
|
+
"ofType": {
|
|
176
|
+
"kind": "SCALAR",
|
|
177
|
+
"name": "String",
|
|
178
|
+
"ofType": null
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"isDeprecated": false,
|
|
182
|
+
"deprecationReason": null
|
|
183
|
+
}
|
|
184
|
+
],
|
|
185
|
+
"inputFields": null,
|
|
186
|
+
"interfaces": [
|
|
187
|
+
{
|
|
188
|
+
"kind": "INTERFACE",
|
|
189
|
+
"name": "Bar",
|
|
190
|
+
"ofType": null
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"kind": "INTERFACE",
|
|
194
|
+
"name": "Foo",
|
|
195
|
+
"ofType": null
|
|
196
|
+
}
|
|
197
|
+
],
|
|
198
|
+
"enumValues": null,
|
|
199
|
+
"possibleTypes": null
|
|
200
|
+
}
|
|
201
|
+
]
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
"""
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def test_operation_gen_nested_interface():
|
|
208
|
+
expected_generated_query = """def query_test_query():
|
|
209
|
+
_op = sgqlc.operation.Operation(_schema_root.query_type, name='TestQuery')
|
|
210
|
+
_op_foo = _op.foo()
|
|
211
|
+
_op_foo__as__Bar = _op_foo.__as__(_schema.Bar)
|
|
212
|
+
_op_foo__as__Bar.bar_field()
|
|
213
|
+
return _op"""
|
|
214
|
+
result_buff = StringIO()
|
|
215
|
+
schema_name = ParsedSchemaName.parse_schema_name('.schema')
|
|
216
|
+
|
|
217
|
+
with StringIO(NESTED_INTERFACE_QUERY) as op_file, StringIO(
|
|
218
|
+
NESTED_INTERFACE_SCHEMA
|
|
219
|
+
) as schema_file:
|
|
220
|
+
operation_gql = [Source(op_file.read(), 'op-gen.gql')]
|
|
221
|
+
schema = load_schema(schema_file)
|
|
222
|
+
gen = CodeGen(
|
|
223
|
+
schema,
|
|
224
|
+
schema_name,
|
|
225
|
+
operation_gql,
|
|
226
|
+
result_buff.write,
|
|
227
|
+
short_names=False,
|
|
228
|
+
)
|
|
229
|
+
gen.write()
|
|
230
|
+
generated_operations = result_buff.getvalue()
|
|
231
|
+
result_buff.close()
|
|
232
|
+
assert expected_generated_query in generated_operations
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|