# 1. Query and Mutation types

Lược đồ bao gồm hai loại gốc:

* **Query** type is a surface of your read API (Loại truy vấn là một bề mặt của API đọc của bạn)
* Mutation type (optional) exposes write API by declaring all possible mutations in your app. (Loại đột biến (tùy chọn) hiển thị API viết bằng cách khai báo tất cả các đột biến có thể có trong ứng dụng của bạn.)

Các loại truy vấn và đột biến là các loại đối tượng thông thường có chứa các trường cấp cơ sở của API của bạn:

```
<?php
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
$queryType = new ObjectType([
  'name'   => 'Query',
  'fields' => [
    'hello' => [
      'type'    => Type::string(),
      'resolve' => function () {
        return 'Hello World!';
      },
    ],
    'hero'  => [
      'type'    => $characterInterface,
      'args'    => [
        'episode' => [
          'type' => $episodeEnum,
        ],
      ],
      'resolve' => function ($rootValue, $args) {
        return StarWarsData::getHero(isset($args['episode']) ? $args['episode'] : null);
      },
    ],
  ],
]);
$mutationType = new ObjectType([
  'name'   => 'Mutation',
  'fields' => [
    'createReview' => [
      'type'    => $createReviewOutput,
      'args'    => [
        'episode' => $episodeEnum,
        'review'  => $reviewInputObject,
      ],
      'resolve' => function ($rootValue, $args) {
        // TODOC
      },
    ],
  ],
]);
?>
```

Hãy nhớ rằng ngoài ý nghĩa đặc biệt của việc khai báo diện tích bề mặt API của bạn, các kiểu đó giống với bất kỳ kiểu đối tượng nào khác và các trường của chúng hoạt động theo cùng một cách.

Kiểu đột biến cũng chỉ là một kiểu đối tượng thông thường. Sự khác biệt là về ngữ nghĩa. Tên trường của kiểu Đột biến thường là động từ và chúng hầu như luôn có đối số - khá thường xuyên với các giá trị đầu vào phức tạp (xem phần Đột biến và Kiểu đầu vào để biết chi tiết).

## Configuration Options <a href="#configuration-options" id="configuration-options"></a>

Phương thức tạo lược đồ mong đợi một phiên bản của GraphQL  Type  SchemaConfig hoặc một mảng có các tùy chọn sau:


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://javascriptuse.gitbook.io/javascript/advanced/1.-query-and-mutation-types.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
