# Root of the GraphQL schema. # # Query and Mutation are declared here with no fields; every other file in this # directory adds to them with `extend type Query` / `extend type Mutation`. # That is what lets the schema be split one file per domain, matching the # one-file-per-domain resolver layout (gqlgen.yml uses layout: follow-schema). # # Time is mapped to Go's time.Time by gqlgen's default scalar handling and is # serialised as RFC 3339. # # These files are the source of truth: after editing one, run # go run github.com/99designs/gqlgen generate # from backend/ to regenerate graph/generated.go and graph/model/models_gen.go. # Note that `#` comments like this one are invisible to clients; a `"""` block # would become a schema description and show up in introspection. scalar Time # Authorisation. There is no middleware in front of /graphql, so a field is # PUBLIC unless it carries one of these. Each is implemented once, in # graph/directives.go, and runs before the field's resolver: # # @admin the request must carry an admin's access token # (error: "admin access required") # @signedIn any valid access token will do # (error: "authentication required") # # Every mutation needs one of them unless it is deliberately public (login, # logout, refreshToken); graph/directives_test.go fails otherwise, and pins # which queries are guarded. Rules that are not a plain gate stay in the # resolver: a post is only editable by its author, `me` answers for whoever is # signed in, and `messages` filters private rows rather than refusing. directive @admin on FIELD_DEFINITION directive @signedIn on FIELD_DEFINITION type Query type Mutation