0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[GraphQL][next.js]graphql-codegenでInputの型が見つからなくて困ったところが解消できた

Posted at

前提

以下の環境

  • next.js

  • typescript

  • GraphQL

結論

user_profiles_insert_inputのようにmutation名_insert_inputの型を指定する

やりたかったこと

Mutationの定義をしたかった。

export const CREATE_USER_PROFILES = gql`
  mutation CreateUserProfiles($userProfiles: [UserProfilesInput!]!) {
    insert_user_profiles(objects: $userProfiles) {
      returning {
        user_id
        profile
      }
    }
  }
`

エラー

エラーに書いてんじゃん、、、

✖ GraphQL Document Validation failed with 3 errors;
      Error 0: Unknown type "UserProfilesInput". Did you mean "user_profiles_insert_input", "user_profiles_set_input", "user_profiles_inc_input", "users_obj_rel_insert_input", or "user_profiles_constraint"?

修正後

UserProfilesInput -> user_profiles_insert_input

export const CREATE_USER_PROFILES = gql`
  mutation CreateUserProfiles($userProfiles: [user_profiles_insert_input!]!) {
    insert_user_profiles(objects: $userProfiles) {
      returning {
        user_id
        profile
      }
    }
  }
`

まとめ

エラーはしっかり読む

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?