Skip to content

Commit 4142db9

Browse files
Merge pull request #177 from AntonioFalcao/feature/graphql-4
Feature/graphql 4
2 parents 55c92a6 + e2fdb19 commit 4142db9

2 files changed

Lines changed: 175 additions & 116 deletions

File tree

README.md

Lines changed: 154 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@ This project exemplifies the implementation and **dockerization** of a simple Ra
1616
|:----:|--- |
1717
|**WebMVC**|[![](https://img.shields.io/docker/pulls/antoniofalcaojr/dotnet5-graphql3-webmvc?style=flat)](https://hub.docker.com/repository/docker/antoniofalcaojr/dotnet5-graphql3-webmvc)|
1818

19-
2019
![home](./.assets/img/home.PNG)
2120

22-
## Environment configuration
23-
24-
### Development
21+
---
2522

26-
##### Secrets
23+
## Running
2724

28-
To configure database resource, `init` secrets in [`./src/Dotnet6.GraphQL4.Store.WebAPI`](./src/Dotnet6.GraphQL4.Store.WebAPI), and then define the `DefaultConnection`:
25+
### Development (secrets)
26+
27+
To configure database resource, `init` secrets in [`./src/Dotnet6.GraphQL4.Store.WebAPI`](./src/Dotnet6.GraphQL4.Store.WebAPI), and then define the `DefaultConnection`:
2928

3029
```bash
3130
dotnet user-secrets init
@@ -39,7 +38,7 @@ dotnet user-secrets init
3938
dotnet user-secrets set "HttpClient:Store" "http://localhost:5000"
4039
```
4140

42-
##### AppSettings
41+
##### AppSettings
4342

4443
If you prefer, is possible to define it on WebAPI [`appsettings.Development.json`](./src/Dotnet6.GraphQL4.Store.WebAPI/appsettings.Development.json) and WebMVC [`appsettings.Development.json`](./src/Dotnet6.GraphQL4.Store.WebMVC/appsettings.Development.json) files:
4544

@@ -62,13 +61,12 @@ WebMCV
6261
}
6362
}
6463
```
65-
___
6664

6765
### Production
6866

69-
Considering use Docker for CD (Continuous Deployment). On respective [compose](./docker-compose.yml) both web applications and sql server are in the same network, and then we can use named hosts. Already defined on WebAPI [`appsettings.json`](./src/Dotnet6.GraphQL4.Store.WebAPI/appsettings.json) and WebMVC [`appsettings.json`](./src/Dotnet6.GraphQL4.Store.WebMVC/appsettings.json) files:
67+
Considering use Docker for CD (Continuous Deployment). On respective [compose](./docker-compose.yml) both web applications and sql server are in the same network, and then we can use named hosts. Already defined on WebAPI [`appsettings.json`](./src/Dotnet6.GraphQL4.Store.WebAPI/appsettings.json) and WebMVC [`appsettings.json`](./src/Dotnet6.GraphQL4.Store.WebMVC/appsettings.json) files:
7068

71-
##### AppSettings
69+
#### AppSettings
7270

7371
WebAPI
7472

@@ -89,6 +87,152 @@ WebMCV
8987
}
9088
}
9189
```
90+
91+
### Docker
92+
93+
The [`./docker-compose.yml`](./docker-compose.yml) provide the `WebAPI`, `WebMVC` and `MS SQL Server` applications:
94+
95+
```bash
96+
docker-compose up -d
97+
```
98+
99+
It's possible to run without a clone of the project using the respective compose:
100+
101+
```yaml
102+
version: "3.7"
103+
104+
services:
105+
mssql:
106+
container_name: mssql
107+
image: mcr.microsoft.com/mssql/server
108+
ports:
109+
- 1433:1433
110+
environment:
111+
SA_PASSWORD: "!MyComplexPassword"
112+
ACCEPT_EULA: "Y"
113+
healthcheck:
114+
test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$$SA_PASSWORD" -Q "SELECT 1" || exit 1
115+
interval: 10s
116+
timeout: 3s
117+
retries: 10
118+
start_period: 10s
119+
networks:
120+
- graphqlstore
121+
122+
webapi:
123+
container_name: webapi
124+
image: antoniofalcaojr/dotnet6-graphql4-webapi
125+
environment:
126+
- ASPNETCORE_URLS=http://*:5000
127+
ports:
128+
- 5000:5000
129+
depends_on:
130+
mssql:
131+
condition: service_healthy
132+
networks:
133+
- graphqlstore
134+
135+
webmvc:
136+
container_name: webmvc
137+
image: antoniofalcaojr/dotnet6-graphql4-webmvc
138+
environment:
139+
- ASPNETCORE_URLS=http://*:7000
140+
ports:
141+
- 7000:7000
142+
depends_on:
143+
- webapi
144+
networks:
145+
- graphqlstore
146+
147+
healthchecks:
148+
container_name: healthchecks-ui
149+
image: xabarilcoding/healthchecksui
150+
depends_on:
151+
mssql:
152+
condition: service_healthy
153+
environment:
154+
- storage_provider=SqlServer
155+
- storage_connection=Server=mssql;Database=Store;User=sa;Password=!MyComplexPassword
156+
- Logging:LogLevel:Default=Debug
157+
- Logging:Loglevel:Microsoft=Warning
158+
- Logging:LogLevel:HealthChecks=Debug
159+
- HealthChecksUI:HealthChecks:0:Name=webapi
160+
- HealthChecksUI:HealthChecks:0:Uri=http://webapi:5000/healthz
161+
- HealthChecksUI:HealthChecks:1:Name=webmvc
162+
- HealthChecksUI:HealthChecks:1:Uri=http://webmvc:7000/healthz
163+
ports:
164+
- 8000:80
165+
networks:
166+
- graphqlstore
167+
168+
networks:
169+
graphqlstore:
170+
driver: bridge
171+
```
172+
### GraphQL Playground
173+
174+
By default **Playground** respond at `http://localhost:5000/ui/playground` but is possible configure the host and many others details in [`../...WebAPI/GraphQL/DependencyInjection/Configure.cs`](./src/Dotnet6.GraphQL4.Store.WebAPI/GraphQL/DependencyInjection/Configure.cs)
175+
176+
```c#
177+
app.UseGraphQLPlayground(
178+
new GraphQLPlaygroundOptions
179+
{
180+
Path = "/ui/playground",
181+
BetaUpdates = true,
182+
RequestCredentials = RequestCredentials.Omit,
183+
HideTracingResponse = false,
184+
EditorCursorShape = EditorCursorShape.Line,
185+
EditorTheme = EditorTheme.Dark,
186+
EditorFontSize = 14,
187+
EditorReuseHeaders = true,
188+
EditorFontFamily = "JetBrains Mono"
189+
});
190+
```
191+
192+
### Health checks
193+
194+
Based on cloud-native concepts, **Readiness** and **Liveness** integrity verification strategies were implemented.
195+
196+
> `/health`
197+
> Just check if the instance is running.
198+
199+
> `/health/live`
200+
> Check if the instance is running and all the dependencies too.
201+
202+
> `/health/ready`
203+
> Check if the instance and all the dependencies are ready to attend to all functionalities.
204+
205+
> `/healthz`
206+
> HealthReport specific for HealthCheck-UI.
207+
208+
Web API
209+
210+
`http://localhost:5000/health/ready`
211+
212+
![Readiness](./.assets/img/Readiness.png)
213+
214+
Web MVC
215+
216+
`http://localhost:7000/health/ready`
217+
218+
![Readiness](./.assets/img/ReadinessMVC.png)
219+
220+
### Dump configuration
221+
222+
It is possible to dump the state of the environment configuration in through the middleware resource `/dump-config` in both applications.
223+
224+
```c#
225+
public void Configure(IApplicationBuilder app)
226+
{
227+
app.UseEndpoints(endpoints =>
228+
{
229+
endpoints.MapDumpConfig(
230+
pattern: "/dump-config",
231+
configInfo: (_configuration as IConfigurationRoot).GetDebugView(),
232+
isDevelopment: _env.IsDevelopment());
233+
});
234+
}
235+
```
92236
___
93237

94238
## Highlights
@@ -284,112 +428,6 @@ public sealed class KayakGraphType : ObjectGraphType<Kayak>
284428

285429
___
286430

287-
## Running
288-
289-
The [`./docker-compose.yml`](./docker-compose.yml) provide the `WebAPI`, `WebMVC` and `MS SQL Server` applications:
290-
291-
```bash
292-
docker-compose up -d
293-
```
294-
295-
It's possible to run without a clone of the project using the respective compose:
296-
297-
```yaml
298-
version: "3.7"
299-
300-
services:
301-
mssql:
302-
container_name: mssql
303-
image: mcr.microsoft.com/mssql/server
304-
ports:
305-
- 1433:1433
306-
environment:
307-
SA_PASSWORD: "!MyComplexPassword"
308-
ACCEPT_EULA: "Y"
309-
healthcheck:
310-
test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$$SA_PASSWORD" -Q "SELECT 1" || exit 1
311-
interval: 10s
312-
timeout: 3s
313-
retries: 10
314-
start_period: 10s
315-
networks:
316-
- graphqlstore
317-
318-
webapi:
319-
container_name: webapi
320-
image: antoniofalcaojr/dotnet6-graphql4-webapi
321-
environment:
322-
- ASPNETCORE_URLS=http://*:5000
323-
ports:
324-
- 5000:5000
325-
depends_on:
326-
mssql:
327-
condition: service_healthy
328-
networks:
329-
- graphqlstore
330-
331-
webmvc:
332-
container_name: webmvc
333-
image: antoniofalcaojr/dotnet6-graphql4-webmvc
334-
environment:
335-
- ASPNETCORE_URLS=http://*:7000
336-
ports:
337-
- 7000:7000
338-
depends_on:
339-
- webapi
340-
networks:
341-
- graphqlstore
342-
343-
networks:
344-
graphqlstore:
345-
driver: bridge
346-
```
347-
### Health checks
348-
349-
Based on cloud-native concepts, **Readiness** and **Liveness** integrity verification strategies were implemented.
350-
351-
> `/health`
352-
> Just check if the instance is running.
353-
354-
> `/health/live`
355-
> Check if the instance is running and all the dependencies too.
356-
357-
> `/health/ready`
358-
> Check if the instance and all the dependencies are ready to attend to all functionalities.
359-
360-
Web API
361-
362-
`http://localhost:5000/health/ready`
363-
364-
![Readiness](./.assets/img/Readiness.png)
365-
366-
Web MVC
367-
368-
`http://localhost:7000/health/ready`
369-
370-
![Readiness](./.assets/img/ReadinessMVC.png)
371-
372-
---
373-
374-
### GraphQL Playground
375-
376-
By default **Playground** respond at `http://localhost:5000/ui/playground` but is possible configure the host and many others details in [`../...WebAPI/GraphQL/DependencyInjection/Configure.cs`](./src/Dotnet6.GraphQL4.Store.WebAPI/GraphQL/DependencyInjection/Configure.cs)
377-
378-
```c#
379-
app.UseGraphQLPlayground(
380-
new GraphQLPlaygroundOptions
381-
{
382-
Path = "/ui/playground",
383-
BetaUpdates = true,
384-
RequestCredentials = RequestCredentials.Omit,
385-
HideTracingResponse = false,
386-
EditorCursorShape = EditorCursorShape.Line,
387-
EditorTheme = EditorTheme.Dark,
388-
EditorFontSize = 14,
389-
EditorReuseHeaders = true,
390-
EditorFontFamily = "JetBrains Mono"
391-
});
392-
```
393431

394432
## Queries
395433

docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,27 @@ services:
4949
networks:
5050
- graphqlstore
5151

52+
healthchecks:
53+
container_name: healthchecks-ui
54+
image: xabarilcoding/healthchecksui
55+
depends_on:
56+
mssql:
57+
condition: service_healthy
58+
environment:
59+
- storage_provider=SqlServer
60+
- storage_connection=Server=mssql;Database=Store;User=sa;Password=!MyComplexPassword
61+
- Logging:LogLevel:Default=Debug
62+
- Logging:Loglevel:Microsoft=Warning
63+
- Logging:LogLevel:HealthChecks=Debug
64+
- HealthChecksUI:HealthChecks:0:Name=webapi
65+
- HealthChecksUI:HealthChecks:0:Uri=http://webapi:5000/healthz
66+
- HealthChecksUI:HealthChecks:1:Name=webmvc
67+
- HealthChecksUI:HealthChecks:1:Uri=http://webmvc:7000/healthz
68+
ports:
69+
- 8000:80
70+
networks:
71+
- graphqlstore
72+
5273
networks:
5374
graphqlstore:
5475
driver: bridge

0 commit comments

Comments
 (0)