Skip to content

Academies (GraphQL)

Academies

Manage Jiu-Jitsu academies using GraphQL queries and mutations.

Schema Types

AcademyType

type AcademyType {
id: ID!
name: String!
professor: String!
location: String!
phone: String
image: String!
}

CreateAcademyInput

input CreateAcademyInput {
name: String!
professor: String!
location: String!
phone: String
image: String!
}

UpdateAcademyInput

input UpdateAcademyInput {
name: String
professor: String
location: String
phone: String
image: String
}

Queries

Get All Academies

Retrieve all academies with optional pagination.

Query:

query GetAcademies {
academies(paginationInput: { limit: 10, offset: 0 }) {
id
name
professor
location
phone
image
}
}

Response:

{
"data": {
"academies": [
{
"id": "507f1f77bcf86cd799439011",
"name": "Alliance Jiu-Jitsu",
"professor": "Fabio Gurgel",
"location": "São Paulo, Brazil",
"phone": "+55 11 98765-4321",
"image": "https://example.com/alliance.jpg"
}
]
}
}

Search Academies by Name

Search for academies by name.

Query:

query SearchAcademies {
searchAcademiesByName(name: "Alliance") {
id
name
professor
location
phone
image
}
}

Mutations

Create Academy

Create a new academy. Requires authentication.

Mutation:

mutation CreateAcademy {
createAcademy(createAcademyInput: {
name: "Gracie Barra"
professor: "Carlos Gracie Jr."
location: "Rio de Janeiro, Brazil"
phone: "+55 21 98765-1234"
image: "https://example.com/gracie-barra.jpg"
}) {
id
name
professor
location
phone
image
}
}

Headers Required:

{
"Authorization": "Bearer YOUR_JWT_TOKEN"
}

Response:

{
"data": {
"createAcademy": {
"id": "507f1f77bcf86cd799439012",
"name": "Gracie Barra",
"professor": "Carlos Gracie Jr.",
"location": "Rio de Janeiro, Brazil",
"phone": "+55 21 98765-1234",
"image": "https://example.com/gracie-barra.jpg"
}
}
}

Update Academy

Update an existing academy. Requires authentication.

Mutation:

mutation UpdateAcademy {
updateAcademy(
id: "507f1f77bcf86cd799439011"
updateAcademyInput: {
phone: "+55 11 99999-8888"
location: "São Paulo, SP, Brazil"
}
) {
id
name
professor
location
phone
image
}
}

Headers Required:

{
"Authorization": "Bearer YOUR_JWT_TOKEN"
}

Delete Academy

Delete an academy by ID. Requires authentication.

Mutation:

mutation RemoveAcademy {
removeAcademy(id: "507f1f77bcf86cd799439011")
}

Headers Required:

{
"Authorization": "Bearer YOUR_JWT_TOKEN"
}

Response:

{
"data": {
"removeAcademy": "Academy deleted successfully"
}
}

Pagination

Use the paginationInput parameter to control pagination:

query GetAcademiesPaginated {
academies(paginationInput: {
limit: 5
offset: 10
}) {
id
name
professor
location
}
}
  • limit: Number of items to return (default: 10)
  • offset: Number of items to skip (default: 0)