feat: enhance quiz schema with JsonList type and add quiz attempt fields
- Introduced a new 'JsonList' scalar type in the GraphQL schema to handle lists of JSON values, improving data structure flexibility. - Updated the Quiz schema to replace 'Json' type with 'JsonList' for user input and questions, ensuring consistent data handling. - Added new fields for retrieving quiz attempts, including individual and multiple attempts, with appropriate authorization checks for user roles. - Enhanced error handling for quiz attempt retrieval to ensure proper access control and user feedback. These changes improve the overall functionality and maintainability of the quiz feature, providing a more robust data model and user experience.
This commit is contained in:
@@ -78,6 +78,10 @@ export interface SchemaBuilderOption {
|
||||
Input: Delta
|
||||
Output: Delta
|
||||
}
|
||||
JsonList: {
|
||||
Input: JsonValue[]
|
||||
Output: JsonValue[]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,6 +164,12 @@ export class Builder extends SchemaBuilder<SchemaBuilderOption> {
|
||||
parseLiteral: (ast: ValueNode) => ast as unknown as Delta,
|
||||
})
|
||||
|
||||
this.scalarType('JsonList', {
|
||||
serialize: (value) => JSON.stringify(value),
|
||||
parseValue: (value: unknown) => JSON.parse(value as string) as JsonValue[],
|
||||
parseLiteral: (ast: ValueNode) => ast as unknown as JsonValue[],
|
||||
})
|
||||
|
||||
this.addScalarType('Json', JSONObjectResolver)
|
||||
this.addScalarType('Upload', GraphQLUpload)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user