Skip to main content

Implementing a New GraphQL Query or Mutation

Steps in order:

  1. Schema — add query/mutation to queries.graphqls or mutations.graphqls; define types in per-entity .graphqls; add Input types as needed
  2. DTO — create EntityDto.java and EntityInput.java in web/dto/; fields must match schema
  3. Mapper — create EntityMapper.java extending BaseMapper<Entity, EntityDto, EntityInput>; add @AfterMapping for bidirectional references
  4. Controller — add @QueryMapping/@MutationMapping method; resolve currentUserId here and pass to service; add @PreAuthorize
  5. Service — add business logic; accept currentUserId as method parameter; use repositories
  6. Repository — extend BaseRepository<Entity>; for workspace subclass fields, query the subclass
  7. Permissions — read endpoints use membership checks; write endpoints use permission matrix checks; add OWNER membership for creators
  8. Validate — run ./mvnw compile; no tests needed

DB: Liquibase is active. Add a new numbered SQL changelog file under src/main/resources/db/changelog/ (e.g. 0006-add-my-table.sql) and include it in db.changelog-master.yaml. Use --liquibase formatted sql header and --changeset author:id tag. JPA ddl-auto is still set to update as a safety net but Liquibase controls the schema.