Task: Fix Concept creation with parentId/rootId via GraphQL API
Fix Concept creation with parentId/rootId via GraphQL API
The KBConceptCreateInput GraphQL schema declares parentId/rootId, but createConcept does not accept them on the backend/Prisma, making it impossible to create concept hierarchies via the API.
Bug
When creating a Concept via the GraphQL API, the schema declares the parentId and rootId fields in KBConceptCreateInput, but passing these fields to createConcept results in an error on the backend/Prisma.
In effect, the API promises support for concept hierarchies, but the create-path does not handle them.
How to Reproduce
- Perform an introspection of
KBConceptCreateInput— verify thatparentIdandrootIdare present. - Create a root Concept.
- Call
createConcept, passingparentIdand/orrootIdto the child Concept. - The backend rejects the request at the Prisma level instead of creating the related entity.
Expected Behavior
If parentId/rootId are declared in the GraphQL input, the backend should:
- accept them;
- validate the existence of the related Concepts;
- correctly record the hierarchical relationships;
- return the created Concept with
parentId/rootIdset.
Alternatively, if these fields are not yet supported, they should not be declared in the public create input until implemented.
Discovery Context
The bug was discovered while creating a Vietnamese language knowledge base on fi1osof.ru. Because of it, we had to abandon structural parent/root relationships and temporarily implement hierarchy only via Markdown cross-linking between Concepts.
What to Check
- GraphQL resolver
createConcept; - mapping of
KBConceptCreateInput→ Prisma create data; - Prisma schema relation fields;
- the difference between create/update paths;
- validation of cycles and invalid root/parent relationships;
- correct setting of
rootIdfor child levels; - tests for creating root, child, and nested Concepts.
Definition of Done
It is possible to create via GraphQL:
- a root Concept;
- a child Concept with
parentId; - a nested Concept with correct
parentIdandrootId;
without backend/Prisma errors, and the relationships are correctly read back via the API.