Skip to content

Latest commit

 

History

History
70 lines (62 loc) · 1.58 KB

README.md

File metadata and controls

70 lines (62 loc) · 1.58 KB

Telemetry

An sample repository to showcase usage of GraphQL in ASP.NET CORE WEB API

In order to run the project follow the below mentioned steps

  1. Set Telemetry.DAL as startup project in visual studio.
  2. Go to file TemporaryDbContextFactory and replace the connection string as per your SQL server.
    2.1 optionsBuilder.UseSqlServer("<<YOUR_SQL_SERVER>>");
  3. Navigate in command prompt to the Telemetry.DAl folder and Run "dotnet ef database update".
  4. This should have created the Database and added the required tables in SQL Server.
  5. Now set Telemetry.API as startup project.
  6. Right click Telemetru.API and navigate to Manager user secrets and replace the ConnectionStrings:TeleMetry to the same connection string given in step 2.
  7. Download and run Serilog-SEQ from https://getseq.net/Download
  8. press ctrl-F5.
  9. Browser must open the page http://localhost:49771/GraphQL/

Sample queries

  1. To get a specific device with a given device id
query TelemetryQuery($id:Int!)
{
   deviceQuery {
   deviceById(id:$id)
    {
      deviceName
    }
  }
}

Under query variables
{
  "id" : 152
}
  1. To get all devices
query TelemetryQuery
{
   deviceQuery {
    allDevices {
      deviceId,
      deviceName
    }
  }
}
  1. To add a device
mutation ($CreateDeviceType:InputCreateDevice!)
{
  deviceMutation{
       addDevice(CreateDeviceType: $CreateDeviceType){
    deviceId
    deviceName
  }

  }

}

Under query variables

{
  "CreateDeviceType":{
    "deviceName":  "TestDevice",
     "description":   "TestDescription"
  }
}