UNPKG

@redocly/graphql-docs

Version:

Redocly GraphQL docs

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