본문 바로가기
기타

[GraphQL] 전체 스키마 조회 쿼리

by 띵앤띵 2022. 9. 22.
728x90
반응형

GraphQL 를 실무에서 접하면서 swagger 같은 API 문서가 없어서 구조 파악에 애를 먹다, 아래의 스키마를 조회할 수 있는 문법을 발견하여 공유한다. !

 

query {
  __schema {
    queryType {
      name
    }
    mutationType {
      name
    }
    subscriptionType {
      name
    }
    types {
      ...FullType
    }
    directives {
      name
      description
      locations
      args {
        ...InputValue
      }
    }
  }
}

fragment FullType on __Type {
  kind
  name
  description
  fields(includeDeprecated: true) {
    name
    description
    args {
      ...InputValue
    }
    type {
      ...TypeRef
    }
    isDeprecated
    deprecationReason
  }
  inputFields {
    ...InputValue
  }
  interfaces {
    ...TypeRef
  }
  enumValues(includeDeprecated: true) {
    name
    description
    isDeprecated
    deprecationReason
  }
  possibleTypes {
    ...TypeRef
  }
}

fragment InputValue on __InputValue {
  name
  description
  type {
    ...TypeRef
  }
  defaultValue
}

fragment TypeRef on __Type {
  kind
  name
  ofType {
    kind
    name
    ofType {
      kind
      name
      ofType {
        kind
        name
        ofType {
          kind
          name
          ofType {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
              }
            }
          }
        }
      }
    }
  }
}

 

GraphQL 엔드포인트에 이 쿼리를 날리면 스키마 전체 상세를 조회할 수 있다.

 

참고 : https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=njw1204&logNo=221645090005

반응형

'기타' 카테고리의 다른 글

[AWS] EC2 pem 키 SSH 접속시 bad permissions  (0) 2022.10.12
[MiniO] minio 사용법  (0) 2022.09.22

댓글