Skip to content

Implement GraphQL API v2 for flexible device and report querying#12

Draft
robgrame with Copilot wants to merge 7 commits into
mainfrom
copilot/implement-api-v2-graphql
Draft

Implement GraphQL API v2 for flexible device and report querying#12
robgrame with Copilot wants to merge 7 commits into
mainfrom
copilot/implement-api-v2-graphql

Conversation

Copilot AI commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

Adds GraphQL API (v2) alongside existing REST API (v1) per roadmap, enabling flexible querying of devices, reports, and events with client-specified field selection.

Implementation

GraphQL Schema (/graphql)

  • Query types: devices, device(id), deviceReports(deviceId, limit), report(id), recentReports(limit), reportEvents(reportId)
  • Types: DeviceType, ReportType, EventType
  • Pagination: 1-200 limit with automatic clamping

Integration

  • HotChocolate 13.9.14 configured in Program.cs
  • Namespace conflict resolution: System.IO.Path vs HotChocolate.Path
  • Banana Cake Pop IDE enabled in development mode

Testing

  • 13 tests covering query operations and error scenarios
  • EF Core InMemory provider for isolated test execution

Documentation

  • /docs/GRAPHQL_API.md with query examples (curl, JavaScript, C#)
  • README updated with GraphQL section
  • Roadmap marked complete

Example

query {
  devices {
    id
    machineName
    manufacturer
    model
    latestDeploymentState
    reportCount
  }
}
curl -X POST http://localhost:5001/graphql \
  -H "Content-Type: application/json" \
  -d '{"query":"{ devices { id machineName lastSeenUtc } }"}'

Notes

  • REST API v1 unchanged, full backward compatibility
  • Mutation for report ingestion implemented but has uint type mapping issues with nested SecureBootRegistrySnapshot - use REST endpoint POST /api/SecureBootReports for ingestion
  • GraphQL optimized for query operations with flexible field selection
Original prompt

This section details on the original issue you should resolve

<issue_title>API v2 with GraphQL</issue_title>
<issue_description>Implement API v2 with GraphQL as described in roadmap</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Nov 7, 2025
Copilot AI and others added 6 commits November 7, 2025 06:09
Co-authored-by: robgrame <12012136+robgrame@users.noreply.github.com>
Co-authored-by: robgrame <12012136+robgrame@users.noreply.github.com>
Co-authored-by: robgrame <12012136+robgrame@users.noreply.github.com>
Co-authored-by: robgrame <12012136+robgrame@users.noreply.github.com>
Co-authored-by: robgrame <12012136+robgrame@users.noreply.github.com>
Co-authored-by: robgrame <12012136+robgrame@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement API v2 using GraphQL Implement GraphQL API v2 for flexible device and report querying Nov 7, 2025
Copilot AI requested a review from robgrame November 7, 2025 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API v2 with GraphQL

2 participants