-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Summary
The @nonExposed decorator lacks an end-to-end integration test that verifies fields marked as non-exposed are actually excluded from the generated GraphQL schema.
Current State
- Unit tests verify that
@nonExposedcorrectly registers field names inconfig.nonExposedGraphQLMetadataKey - Tests cover
@Entity,@ReadModel,@Command, and@Queryclass decorators - However, the GraphQL generator tests stub out internals, so we don't have a test that:
- Defines a class with
@nonExposedfields - Generates the actual GraphQL schema
- Asserts the non-exposed fields are NOT present in the schema
- Defines a class with
Proposed Solution
Add an integration test that:
it('excludes @nonExposed fields from generated GraphQL schema', () => {
@ReadModel({ authorize: 'all' })
class TestReadModel {
@field(type => UUID)
public readonly id!: UUID
@field()
public readonly publicField!: string
@nonExposed
@field()
public readonly secretField!: string
}
// Register the read model in config
// Generate the GraphQL schema
const schema = GraphQLGenerator.generateSchema(config)
// Get the TestReadModel type from schema
const testReadModelType = schema.getType('TestReadModel') as GraphQLObjectType
const fields = testReadModelType.getFields()
// Assert secretField is NOT in the schema
expect(fields['publicField']).to.exist
expect(fields['secretField']).to.be.undefined
})Context
This was identified while fixing a timing bug in @nonExposed (commit ef27cb9). The fix is architecturally sound and follows the same pattern as @sequencedBy, but an integration test would provide additional confidence.
Files to Consider
packages/core/test/services/graphql/graphql-generator.test.tspackages/core/test/services/graphql/graphql-query-generator.test.ts
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels