UNPKG

@redocly/graphql-docs

Version:

Redocly GraphQL docs

2 lines (1 loc) 1.94 kB
import{jsx as t,jsxs as r}from"react/jsx-runtime";import{isInputObjectType as a}from"graphql";import{memo as c,useMemo as f}from"react";import{useThemeHooks as u}from"@redocly/theme";import{SplittedWbrText as h}from"../../../shared/index.js";import{MiddleSection as g,RightSection as y,useStore as T}from"../../app/index.js";import{isFieldsType as w}from"../../schema/index.js";import{TypeExample as x}from"../../examples/index.js";import{Markdown as j}from"../../markdown/index.js";import{useSettings as F}from"../../settings/index.js";import{ShareLink as I}from"../../navigation/index.js";import{Box as n}from"../../common/index.js";import{FieldsGroupHeader as k,StyledItemHeader as b}from"../../common/components/Headers.js";import{Annotation as S,FieldList as L,FieldView as M,GroupTypeList as H,ReferenceList as O}from"../components/index.js";import{useItemLink as R}from"../hooks/use-item-link.js";function v({name:i}){const o=T(),{markdown:m}=F(),{useTranslate:l}=u(),{translate:p}=l(),d=R(i),{type:e,references:s}=f(()=>({type:o?.getType(i),references:o?.getTypeReferences(i)}),[i,o]);return w(e)?r(n,{"data-testid":e.name,direction:"row",wrap:"wrap",gap:"64px",children:[r(g,{"data-testid":"object-item",children:[r(b,{"data-testid":"title",children:[t(I,{to:d,"aria-label":`link to ${e.name}`}),t(h,{text:e.name})]}),t(S,{"data-testid":"object-description",children:t(j,{rawMarkdown:e.description,parser:m?.parser})}),Object.values(e.getFields()).length?t(n,{direction:"column",wrap:"wrap",children:t(L,{fields:Object.values(e.getFields()),renderField:M})}):null,!a(e)&&e.getInterfaces().length?r(n,{direction:"column",children:[t(k,{"data-testid":"implements-interfaces",children:p("graphql.implementedInterfaces","Implements interfaces")}),t(H,{types:e.getInterfaces()})]}):null]}),r(y,{"data-testid":"right-section",children:[t(x,{type:e}),s?.length?t(O,{references:s}):null]})]}):null}const P=c(v);export{P as FieldsTypeItem};