A walk in GraphQL
.Net Core Setup
Requirements
- Net Core 3.1.3
- DotNet Command (.NET Core CLI)
Create Project
Execute
[source code path]
> dotnet new webapi -n GraphQLNetCore --auth none
Add Dependencies
Execute
[csproj's path created above]
> dotnet add package GraphQL -v 2.4.0
> dotnet add package Microsoft.EntityFrameworkCore -v 3.1.3
> dotnet add package Microsoft.EntityFrameworkCore.InMemory -v 3.1.3
> dotnet add package GraphQL.Server.Ui.Playground -v 3.4.0
Add Run Profile by edit [.\Property\launchSettings.json] file
Open IDE (VS 2019 ir VS Code) to add new item to collection profile:
"Playground": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "ui/playground",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:59370/"
}
Add Run Profile by edit [.\appSettings.json] file
- Open IDE (VS 2019 ir VS Code) to add new entry:
"GraphQLPath": "/graphql"
Run Application
Using Visual Studio (2019/17)
The VS is an excellent for run the playground.
- Go to .net core folder exercise.
- Open the project (.csproj file)
- F5.
DotNet Command (.NET Core CLI)
- Open CMD
- Go to project folder
- Execute Dotnet Run
- from any browse type [http://localhost:59370/ui/playground] in order to test any query or mutation