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