Skip to content

Commit bad7a28

Browse files
author
Sergio García Prado
authored
Merge pull request #330 from minos-framework/0.6.x
0.6.x (2)
2 parents e237d2f + 72cd513 commit bad7a28

File tree

5 files changed

+73
-49
lines changed

5 files changed

+73
-49
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,17 @@ docs:
2727
$(MAKE) --directory=packages/plugins/minos-broker-kafka install docs
2828
cp -R packages/plugins/minos-broker-kafka/docs/_build/html $(DOCS_TARGET)/plugins/minos-broker-kafka
2929

30+
$(MAKE) --directory=packages/plugins/minos-broker-rabbitmq install docs
31+
cp -R packages/plugins/minos-broker-rabbitmq/docs/_build/html $(DOCS_TARGET)/plugins/minos-broker-rabbitmq
32+
3033
$(MAKE) --directory=packages/plugins/minos-discovery-minos install docs
3134
cp -R packages/plugins/minos-discovery-minos/docs/_build/html $(DOCS_TARGET)/plugins/minos-discovery-minos
3235

36+
$(MAKE) --directory=packages/plugins/minos-http-aiohttp install docs
37+
cp -R packages/plugins/minos-http-aiohttp/docs/_build/html $(DOCS_TARGET)/plugins/minos-http-aiohttp
38+
39+
$(MAKE) --directory=packages/plugins/minos-router-graphql install docs
40+
cp -R packages/plugins/minos-router-graphql/docs/_build/html $(DOCS_TARGET)/plugins/minos-router-graphql
41+
42+
3343
poetry run $(MAKE) --directory=docs html

packages/plugins/minos-broker-rabbitmq/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ Most development discussions take place over the [GitHub Issues](https://github.
6363

6464
## License
6565

66-
This project is distributed under the [MIT](https://raw.githubusercontent.com/minos-framework/minos-python/main/LICENSE) license.
66+
This project is distributed under the [MIT](https://raw.githubusercontent.com/minos-framework/minos-python/main/LICENSE) license.

packages/plugins/minos-discovery-minos/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ Most development discussions take place over the [GitHub Issues](https://github.
5252

5353
## License
5454

55-
This project is distributed under the [MIT](https://raw.githubusercontent.com/minos-framework/minos-python/main/LICENSE) license.
55+
This project is distributed under the [MIT](https://raw.githubusercontent.com/minos-framework/minos-python/main/LICENSE) license.

packages/plugins/minos-http-aiohttp/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212

1313
## Summary
1414

15-
Minos is a framework which helps you create [reactive](https://www.reactivemanifesto.org/) microservices in Python.
16-
Internally, it leverages Event Sourcing, CQRS and a message driven architecture to fulfil the commitments of an
17-
asynchronous environment.
15+
Minos is a framework which helps you create [reactive](https://www.reactivemanifesto.org/) microservices in Python. Internally, it leverages Event Sourcing, CQRS and a message driven architecture to fulfil the commitments of an asynchronous environment.
1816

1917
## Installation
2018

@@ -51,6 +49,7 @@ The source code of this project is hosted at the [GitHub Repository](https://git
5149
For usage questions, the best place to go to is [StackOverflow](https://stackoverflow.com/questions/tagged/minos).
5250

5351
## Discussion and Development
52+
5453
Most development discussions take place over the [GitHub Issues](https://github.com/minos-framework/minos-python/issues). In addition, a [Gitter channel](https://gitter.im/minos-framework/community) is available for development-related questions.
5554

5655
## License

packages/plugins/minos-router-graphql/README.md

Lines changed: 59 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Modify `config.yml` file:
2727
```yaml
2828
...
2929
routers:
30-
- minos.plugins.graphql.GraphQlRouter
30+
- minos.plugins.graphql.GraphQlRouter
3131
...
3232
```
3333

@@ -36,6 +36,7 @@ routers:
3636
### Define your business operation
3737

3838
We will use simple query for this demonstration:
39+
3940
```python
4041
from graphql import (
4142
GraphQLString,
@@ -57,27 +58,32 @@ class QueryService:
5758
```
5859

5960
### Execute query
61+
6062
Send `post` request to `http://your_ip_address:port/service_name/graphql` endpoint:
63+
6164
```json
6265
{
63-
"query": "{ SimpleQuery }"
66+
"query": "{ SimpleQuery }"
6467
}
6568
```
6669

6770
You will receive:
71+
6872
```json
6973
{
70-
"data": {
71-
"SimpleQuery": "ABCD"
72-
},
73-
"errors": []
74+
"data": {
75+
"SimpleQuery": "ABCD"
76+
},
77+
"errors": []
7478
}
7579
```
80+
7681
That's all you need to make it work !
7782

7883
For more information about graphql and how to define fields or structures, please see the official [graphql-core](https://github.com/graphql-python/graphql-core). library.
7984

8085
## Decorators
86+
8187
There are 2 types of decorators, one for `queries` and one for `mutations` (commands).
8288

8389
```python
@@ -86,18 +92,21 @@ def test_query(self, request: Request):
8692
...
8793
return Responnse(...)
8894

95+
8996
@enroute.graphql.command(name="TestCommand", argument=GraphQLString, output=GraphQLString)
9097
def test_command(self, request: Request):
9198
...
9299
return Responnse(...)
93100
```
94101

95102
Both decorators have the following arguments:
96-
- `name`: The name of the query or command
97-
- `argument` [Optional]: The arguments it receives, if any.
98-
- `output`: The expected output.
103+
104+
- `name`: The name of the query or command
105+
- `argument` [Optional]: The arguments it receives, if any.
106+
- `output`: The expected output.
99107

100108
### Resolvers
109+
101110
As you have seen above, the decorator does not specify the function that will resolve it.
102111

103112
This is because it automatically takes the decorated function.
@@ -114,9 +123,11 @@ def test_query(self, request: Request):
114123
The function in charge of resolving the query is the decorated function `test_query`.
115124

116125
### Queries (Query Service)
126+
117127
Queries are used for a single purpose as their name indicates and that is to obtain information, that is, for queries.
118128

119129
Base structure example:
130+
120131
```python
121132
class QueryService:
122133
@enroute.graphql.query(name="TestQuery", argument=GraphQLString, output=GraphQLString)
@@ -126,6 +137,7 @@ class QueryService:
126137
```
127138

128139
More complex example:
140+
129141
```python
130142
from graphql import (
131143
GraphQLBoolean,
@@ -146,7 +158,6 @@ from minos.networks import (
146158
enroute,
147159
)
148160

149-
150161
user_type = GraphQLObjectType(
151162
"UserType",
152163
{
@@ -180,34 +191,36 @@ If you POST `{service_name}/graphql` endpoint passing the query and variables:
180191

181192
```json
182193
{
183-
"query": "query ($userId: Int!) { GetUser(request: $userId) {id firstName lastName tweets verified}}",
184-
"variables": {
185-
"userId": 3
186-
}
194+
"query": "query ($userId: Int!) { GetUser(request: $userId) {id firstName lastName tweets verified}}",
195+
"variables": {
196+
"userId": 3
197+
}
187198
}
188199
```
189200

190201
Yoy will receive:
191202

192203
```json
193204
{
194-
"data": {
195-
"GetUser": {
196-
"id": "3",
197-
"firstName": "Jack",
198-
"lastName": "Johnson",
199-
"tweets": 563,
200-
"verified": true
201-
}
202-
},
203-
"errors": []
205+
"data": {
206+
"GetUser": {
207+
"id": "3",
208+
"firstName": "Jack",
209+
"lastName": "Johnson",
210+
"tweets": 563,
211+
"verified": true
212+
}
213+
},
214+
"errors": []
204215
}
205216
```
206217

207218
### Mutations (Command Service)
219+
208220
Mutations are used to create, update or delete information.
209221

210222
Base structure example:
223+
211224
```python
212225
class CommandService:
213226
@enroute.graphql.command(name="TestQuery", argument=GraphQLString, output=GraphQLString)
@@ -217,6 +230,7 @@ class CommandService:
217230
```
218231

219232
More complex example:
233+
220234
```python
221235
from graphql import (
222236
GraphQLBoolean,
@@ -239,7 +253,6 @@ from minos.networks import (
239253
enroute,
240254
)
241255

242-
243256
user_type = GraphQLObjectType(
244257
"UserType",
245258
{
@@ -251,7 +264,6 @@ user_type = GraphQLObjectType(
251264
},
252265
)
253266

254-
255267
user_input_type = GraphQLInputObjectType(
256268
"UserInputType",
257269
{
@@ -292,37 +304,39 @@ If you POST `{service_name}/graphql` endpoint passing the query and variables:
292304

293305
```json
294306
{
295-
"query": "mutation ($userData: UserInputType!) { CreateUser(request: $userData) {id, firstName, lastName, tweets, verified}}",
296-
"variables": {
297-
"userData": {
298-
"firstName": "John",
299-
"lastName": "Doe",
300-
"tweets": 42,
301-
"verified": true
302-
}
307+
"query": "mutation ($userData: UserInputType!) { CreateUser(request: $userData) {id, firstName, lastName, tweets, verified}}",
308+
"variables": {
309+
"userData": {
310+
"firstName": "John",
311+
"lastName": "Doe",
312+
"tweets": 42,
313+
"verified": true
303314
}
315+
}
304316
}
305317
```
306318

307319
Yoy will receive:
308320

309321
```json
310322
{
311-
"data": {
312-
"CreateUser": {
313-
"id": "4kjjj43-l23k4l3-325kgaa2",
314-
"firstName": "John",
315-
"lastName": "Doe",
316-
"tweets": 42,
317-
"verified": true
318-
}
319-
},
320-
"errors": []
323+
"data": {
324+
"CreateUser": {
325+
"id": "4kjjj43-l23k4l3-325kgaa2",
326+
"firstName": "John",
327+
"lastName": "Doe",
328+
"tweets": 42,
329+
"verified": true
330+
}
331+
},
332+
"errors": []
321333
}
322334
```
323335

324336
### Get Schema
337+
325338
By calling `{service_name}/graphql/schema` with `GET` method, you will receive the schema:
339+
326340
```text
327341
"type Query {\n GetUser(request: Int): UserType\n}\n\ntype UserType {\n id: ID!\n firstName: String!\n lastName: String!\n tweets: Int\n verified: Boolean!\n}\n\ntype Mutation {\n CreateUser(request: UserInputType!): UserType\n}\n\ninput UserInputType {\n firstName: String!\n lastName: String!\n tweets: Int\n verified: Boolean\n}"
328342
```
@@ -340,6 +354,7 @@ The source code of this project is hosted at the [GitHub Repository](https://git
340354
For usage questions, the best place to go to is [StackOverflow](https://stackoverflow.com/questions/tagged/minos).
341355

342356
## Discussion and Development
357+
343358
Most development discussions take place over the [GitHub Issues](https://github.com/minos-framework/minos-python/issues). In addition, a [Gitter channel](https://gitter.im/minos-framework/community) is available for development-related questions.
344359

345360
## License

0 commit comments

Comments
 (0)