VS Code の Thunder Client で graphql を使う

添付ファイル1
No.2358
06/01 10:39

edit

添付ファイル

nestjs + graphql で input の @IsOptional() がうまく聞かない時の修正箇所

● nestjs + graphql で input の @IsOptional() がうまく聞かない時の修正箇所

teamName を オプショナルに変更する

@Field()
teamName: string;

     ↓
✅ @IsOptional() と { nullable: true } を加えるとオプショナルになります

@IsOptional()
@Field({ nullable: true })
teamName?: string;

❌ { nullable: true } が抜けていると オプショナルになりません

@IsOptional()
@Field()
teamName?: string;
No.2357
05/30 09:48

edit

全てのクエリを取得する

● (grapql) 全てのクエリを取得する

query {
 __schema {
   queryType {
     fields {
       name
     }
   }
 }
}

● (grapql) 全てのミューテーションを取得する

query {
  __schema {
    mutationType {
      fields {
        name
      }
    }
  }
}

● (grapql) 全ての作スクリプションを取得する

query {
 __schema {
   subscriptionType {
     fields {
       name
     }
   }
 }
}
No.2356
05/29 15:55

edit

github の graphql API を使用する

● GitHub GraphQL API (エクスプローラー)

https://docs.github.com/ja/graphql/overview/explorer

● 自分の ログイン名 アイコン、URLなどを取得する

query { 
  viewer { 
    login,name,id,avatarUrl
  }
}

● 指定したID(この例では hogehoge)のアイコンURLを取得する(ユーザー名直接渡し)

query { 
	user(login:"hogehoge"){
    name, avatarUrl
  }
}

● 指定したID(この例では hogehoge)のアイコンURLを取得する(ユーザー名 変数 渡し)

変数を $userName: String! で定義します。

query ($userName: String!) { 
	user(login:$userName){
    name, avatarUrl
  }
}

QUERY VARIABLES で渡します

{
  "userName": "hogehoge"
}

GitHub GraphQL APIでPull Requestの作成|Showcase Gig Product Team Blog|note

GitHub の GraphQL API Explorer の使い方|まくろぐ

No.2318
06/01 10:16

edit