콘텐츠로 이동

개별 레코드 변형

8base의 자동 생성된 GraphQL 뮤테이션 작업을 사용하여 개별 테이블 레코드를 생성, 업데이트 및 삭제할 수 있습니다.

다음 예제에서는 firstName, email, age와 같은 필드 및 관계를 포함하는 students라는 테이블이 있습니다.

레코드 데이터를 정의하는 입력 인수를 사용하여 새 레코드를 생성합니다.

요청

mutation MyMutation1 {
createStudents(
input: {
firstName: "John",
lastName: "Doe",
email: "john.doe@example.com",
age: 24,
city: "2900562f-d036-486d-be98-9ebf064c27fe"
}
) {
id
firstName
lastName
email
age
city {
id
nameCity
}
}
}

응답

{
"data": {
"createStudents": {
"id": "2685ec12-a4c7-491d-a155-d0b09190993b",
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@example.com",
"age": 24,
"city": {
"id": "2900562f-d036-486d-be98-9ebf064c27fe",
"nameCity": "Houston"
}
}
}
}

id 및 입력 인수를 사용하여 레코드를 업데이트합니다.

요청

mutation MyMutation1 {
updateStudents(
id: "2685ec12-a4c7-491d-a155-d0b09190993b",
input: {
age: 23
}
) {
id
firstName
age
}
}

응답

{
"data": {
"updateStudents": {
"id": "2685ec12-a4c7-491d-a155-d0b09190993b",
"firstName": "John",
"age": 23
}
}
}

id 인수를 사용하여 레코드를 삭제합니다.

요청

mutation MyMutation1 {
deleteStudents(
id: "2685ec12-a4c7-491d-a155-d0b09190993b"
)
}

응답

{
"data": {
"deleteStudents": true
}
}