UNPKG

@redocly/graphql-docs

Version:

Redocly GraphQL docs

2 lines (1 loc) 1.85 kB
import{jsx as t,jsxs as r}from"react/jsx-runtime";import{memo as h}from"react";import{isRequiredArgument as R}from"graphql";import{Admonition as g,useThemeHooks as k}from"@redocly/theme";import{SplittedWbrText as y}from"../../../shared/index.js";import{Markdown as c}from"../../markdown/index.js";import{useSettings as F}from"../../settings/index.js";import{Box as f}from"../../common/index.js";import{isDeprecatedField as D}from"../../schema/helpers/is-deprecated.js";import{PanelAnnotation as q,FieldName as j,FieldNameBox as T,FieldInfo as B,FieldLink as M}from"./styled.js";import{ReturnTypeDetails as S}from"./ReturnTypeDetails.js";import{DefaultValue as V}from"./DefaultValue.js";import{RequiresScopesButton as b}from"./RequiresScopesButton.js";function I({field:e,expanded:u,isArgument:o,parentType:n,parentName:i}){const{markdown:s}=F(),{useTranslate:l}=k(),{translate:w}=l(),m=D(e),x=o&&R(e),a=o?"argument":"field",d=n?.name,p=o?i?`arg-${i}-${e.name}`:`arg-${e.name}`:d?`${d}-${e.name}`:e.name,$=`#${p}`;return r(f,{"data-testid":`${a}-item`,direction:"column",rowGap:.5,children:[r(T,{"data-testid":e.name,direction:"row",children:[r(j,{"data-testid":`${a}-name`,isDeprecated:m,children:[t(M,{to:$,"aria-label":`link to ${p}`}),t(y,{text:e.name})]}),t(S,{"data-testid":"return-type",type:e.type,inline:!e.args?.length,deprecated:m,required:x})]}),r(B,{gutter:0,expanded:u,direction:"column","data-testid":e.name+"-type",children:[t(V,{"data-testid":"default-value",defaultValue:e.defaultValue}),t(q,{"data-testid":`${a}-description`,children:t(c,{rawMarkdown:e.description,parser:s?.parser,isField:!0})}),e.deprecationReason&&t(g,{name:w("graphql.deprecationReason","Deprecation reason"),type:"warning",children:t(c,{rawMarkdown:e.deprecationReason,parser:s?.parser})})]}),t(b,{field:e,parentType:n})]})}const K=h(I);export{K as FieldRow};