Table of Contents
This project is a GraphQL API for handling basic information in Rocco Company.
Here we will find Companies and Employees.
This GraphQL API has build using ASP.NET Core Web API using .NET 6.0. Some of the Nuget Packages used here are:
- GraphQL for .NET
- Entity Framework Core for SQL Server
- GraphQL Playground integration for ASP.NET Core
Here some steps to run the application.
- Visual Studio 2022 or Visual Studio Code
- SDK .NET 6
- SQL Server Express 2019 or other version will works.
To start using the application you should.
- Clone the repo.
git clone https://github.com/helibertoarias/RoccoGraphQL.git
- Open the solution RoccoGraphQL.sln and build to restore the Nuget Packages.
- Open the file ./RoccoGraphQL/appsettings.development.json and update the user and password. Here there is an example using a SQL Express connection.
"ConnectionStrings": { "RoccoConnectionString": "localhost\\SQLEXPRESS; database=Rocco; Integrated Security=true",
- In Visual Studio 2022 open a new terminal Package Manager Console. Then, run the following command to create the database.
Update-Database
- After this you can run the application. The Playground UI will show up in the following URL https://localhost:7070/ui/playground
To validate the GraphQL API you can try this in the Playground UI.
- Simple query: Run a query to get information for all companies.
{
companies {
name
address
country
}
}
- Related query: Run a query to get information for all companies and related employees.
{
companies {
name
employees {
name
position
}
}
}
- Mutation: Run this mutation to add a new company.
mutation($company: companyInput!){
createCompany(company: $company){
name
address
country
}
}
// Set this into the query variables section
{
"company": {
"name": "My company ACME",
"address": "Street 90",
"country": "USA"
}
}
Heliberto Arias - @helibertoarias - [email protected]
Project Link: https://github.com/helibertoarias/RoccoGraphQL