Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,17 @@ docs:
$(MAKE) --directory=packages/plugins/minos-broker-kafka install docs
cp -R packages/plugins/minos-broker-kafka/docs/_build/html $(DOCS_TARGET)/plugins/minos-broker-kafka

$(MAKE) --directory=packages/plugins/minos-broker-rabbitmq install docs
cp -R packages/plugins/minos-broker-rabbitmq/docs/_build/html $(DOCS_TARGET)/plugins/minos-broker-rabbitmq

$(MAKE) --directory=packages/plugins/minos-discovery-minos install docs
cp -R packages/plugins/minos-discovery-minos/docs/_build/html $(DOCS_TARGET)/plugins/minos-discovery-minos

$(MAKE) --directory=packages/plugins/minos-http-aiohttp install docs
cp -R packages/plugins/minos-http-aiohttp/docs/_build/html $(DOCS_TARGET)/plugins/minos-http-aiohttp

$(MAKE) --directory=packages/plugins/minos-router-graphql install docs
cp -R packages/plugins/minos-router-graphql/docs/_build/html $(DOCS_TARGET)/plugins/minos-router-graphql


poetry run $(MAKE) --directory=docs html
2 changes: 1 addition & 1 deletion packages/plugins/minos-broker-rabbitmq/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ Most development discussions take place over the [GitHub Issues](https://github.

## License

This project is distributed under the [MIT](https://raw.githubusercontent.com/minos-framework/minos-python/main/LICENSE) license.
This project is distributed under the [MIT](https://raw.githubusercontent.com/minos-framework/minos-python/main/LICENSE) license.
2 changes: 1 addition & 1 deletion packages/plugins/minos-discovery-minos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ Most development discussions take place over the [GitHub Issues](https://github.

## License

This project is distributed under the [MIT](https://raw.githubusercontent.com/minos-framework/minos-python/main/LICENSE) license.
This project is distributed under the [MIT](https://raw.githubusercontent.com/minos-framework/minos-python/main/LICENSE) license.
5 changes: 2 additions & 3 deletions packages/plugins/minos-http-aiohttp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

## Summary

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.
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.

## Installation

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

## Discussion and Development

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.

## License
Expand Down
103 changes: 59 additions & 44 deletions packages/plugins/minos-router-graphql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Modify `config.yml` file:
```yaml
...
routers:
- minos.plugins.graphql.GraphQlRouter
- minos.plugins.graphql.GraphQlRouter
...
```

Expand All @@ -36,6 +36,7 @@ routers:
### Define your business operation

We will use simple query for this demonstration:

```python
from graphql import (
GraphQLString,
Expand All @@ -57,27 +58,32 @@ class QueryService:
```

### Execute query

Send `post` request to `http://your_ip_address:port/service_name/graphql` endpoint:

```json
{
"query": "{ SimpleQuery }"
"query": "{ SimpleQuery }"
}
```

You will receive:

```json
{
"data": {
"SimpleQuery": "ABCD"
},
"errors": []
"data": {
"SimpleQuery": "ABCD"
},
"errors": []
}
```

That's all you need to make it work !

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.

## Decorators

There are 2 types of decorators, one for `queries` and one for `mutations` (commands).

```python
Expand All @@ -86,18 +92,21 @@ def test_query(self, request: Request):
...
return Responnse(...)


@enroute.graphql.command(name="TestCommand", argument=GraphQLString, output=GraphQLString)
def test_command(self, request: Request):
...
return Responnse(...)
```

Both decorators have the following arguments:
- `name`: The name of the query or command
- `argument` [Optional]: The arguments it receives, if any.
- `output`: The expected output.

- `name`: The name of the query or command
- `argument` [Optional]: The arguments it receives, if any.
- `output`: The expected output.

### Resolvers

As you have seen above, the decorator does not specify the function that will resolve it.

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

### Queries (Query Service)

Queries are used for a single purpose as their name indicates and that is to obtain information, that is, for queries.

Base structure example:

```python
class QueryService:
@enroute.graphql.query(name="TestQuery", argument=GraphQLString, output=GraphQLString)
Expand All @@ -126,6 +137,7 @@ class QueryService:
```

More complex example:

```python
from graphql import (
GraphQLBoolean,
Expand All @@ -146,7 +158,6 @@ from minos.networks import (
enroute,
)


user_type = GraphQLObjectType(
"UserType",
{
Expand Down Expand Up @@ -180,34 +191,36 @@ If you POST `{service_name}/graphql` endpoint passing the query and variables:

```json
{
"query": "query ($userId: Int!) { GetUser(request: $userId) {id firstName lastName tweets verified}}",
"variables": {
"userId": 3
}
"query": "query ($userId: Int!) { GetUser(request: $userId) {id firstName lastName tweets verified}}",
"variables": {
"userId": 3
}
}
```

Yoy will receive:

```json
{
"data": {
"GetUser": {
"id": "3",
"firstName": "Jack",
"lastName": "Johnson",
"tweets": 563,
"verified": true
}
},
"errors": []
"data": {
"GetUser": {
"id": "3",
"firstName": "Jack",
"lastName": "Johnson",
"tweets": 563,
"verified": true
}
},
"errors": []
}
```

### Mutations (Command Service)

Mutations are used to create, update or delete information.

Base structure example:

```python
class CommandService:
@enroute.graphql.command(name="TestQuery", argument=GraphQLString, output=GraphQLString)
Expand All @@ -217,6 +230,7 @@ class CommandService:
```

More complex example:

```python
from graphql import (
GraphQLBoolean,
Expand All @@ -239,7 +253,6 @@ from minos.networks import (
enroute,
)


user_type = GraphQLObjectType(
"UserType",
{
Expand All @@ -251,7 +264,6 @@ user_type = GraphQLObjectType(
},
)


user_input_type = GraphQLInputObjectType(
"UserInputType",
{
Expand Down Expand Up @@ -292,37 +304,39 @@ If you POST `{service_name}/graphql` endpoint passing the query and variables:

```json
{
"query": "mutation ($userData: UserInputType!) { CreateUser(request: $userData) {id, firstName, lastName, tweets, verified}}",
"variables": {
"userData": {
"firstName": "John",
"lastName": "Doe",
"tweets": 42,
"verified": true
}
"query": "mutation ($userData: UserInputType!) { CreateUser(request: $userData) {id, firstName, lastName, tweets, verified}}",
"variables": {
"userData": {
"firstName": "John",
"lastName": "Doe",
"tweets": 42,
"verified": true
}
}
}
```

Yoy will receive:

```json
{
"data": {
"CreateUser": {
"id": "4kjjj43-l23k4l3-325kgaa2",
"firstName": "John",
"lastName": "Doe",
"tweets": 42,
"verified": true
}
},
"errors": []
"data": {
"CreateUser": {
"id": "4kjjj43-l23k4l3-325kgaa2",
"firstName": "John",
"lastName": "Doe",
"tweets": 42,
"verified": true
}
},
"errors": []
}
```

### Get Schema

By calling `{service_name}/graphql/schema` with `GET` method, you will receive the schema:

```text
"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}"
```
Expand All @@ -340,6 +354,7 @@ The source code of this project is hosted at the [GitHub Repository](https://git
For usage questions, the best place to go to is [StackOverflow](https://stackoverflow.com/questions/tagged/minos).

## Discussion and Development

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.

## License
Expand Down