Unique field not working [v4.3.8]

System Information

Strapi Version: v4.3.8
Database: PostgreSQL
Node Version: v16.17.0
NPM Version: v8.3.2
Yarn Version: v1.22.17


hi,I define a content-type, one of the fields is unique.
When I create data using graphql API,an entry with the same field was created, the unique field not working.

type Tag {
  name: String!        // this field unique
  createdAt: DateTime
  updatedAt: DateTime
  publishedAt: DateTime
}
const endpoint = "http://localhost:1337/graphql";

async function createTag(name) {
  name = name.trim();
  const query = gql`
    mutation createTag($data: TagInput!) {
      createTag(data: $data) {
        data {
          id
        }
      }
    }
  `;

  return new Promise((resolve, reject) => {
    request(endpoint, query, {
      data: { name, publishedAt: new Date().toISOString() },
    })
      .then((res) => {
        const {
          createTag: { data },
        } = res;
        resolve(data);
      })
      .catch((err) => {
        reject(err);
      });
  });
}

(async () => {
  const tags = [
    "tagA",
    "tagA",
  ];

  tags.forEach(async tag => {
    try {
      createTag(tag);
    } catch (error) {
      console.log(error);
    }
  });
})();

Running the above code for the first time does not detect unique.

The second run will detect unique and throw an exception.

Can anyone tell me what is the problem.

Thank you!

@ DMehaffy