-
-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
Problem Summary
The graphql_codegen build runner does not validate GraphQL queries against the schema. Invalid queries that don't match the schema (missing required parameters, invalid fields, etc.) pass the build process successfully but will fail at runtime.
Concrete Example
The Schema Definition
# lib/schema.graphql
type Query {
myItems(
requiredParam: Boolean! # This is a REQUIRED parameter
optionalFilter: String
skip: Int
take: Int
): ItemsCollectionSegment
}The Invalid Query
# lib/GetMyItems.graphql
query GetMyItems($filter: String, $skip: Int, $take: Int) {
myItems(optionalFilter: $filter, skip: $skip, take: $take) {
items {
id
name
description
}
pageInfo {
hasNextPage
hasPreviousPage
}
}
}The Problem
The query is missing the required requiredParam parameter, but:
- ✅
dart run build_runner buildcompletes successfully - ✅ No errors or warnings are generated
- ✅ Dart code is generated without issues
- ❌ The query will fail at runtime when executed
Question
Is there any existing mechanism or configuration option in graphql_codegen to enable schema validation?
If not, are there any recommended approaches such as:
- Configuration options we're missing?
- Alternative build_runner builders that provide validation?
- Separate validation tools that integrate with Dart/Flutter projects?
Metadata
Metadata
Assignees
Labels
No labels