@redocly/graphql-docs
Version:
Redocly GraphQL docs
2 lines (1 loc) • 1.82 kB
JavaScript
import{jsx as t,jsxs as r}from"react/jsx-runtime";import{isInputObjectType as d}from"graphql";import{memo as l,useMemo as f}from"react";import{useThemeHooks as u}from"@redocly/theme";import{MiddleSection as g,RightSection as h,useStore as y}from"../../app/index.js";import{isFieldsType as T}from"../../schema/index.js";import{TypeExample as w}from"../../examples/index.js";import{Markdown as j}from"../../markdown/index.js";import{useSettings as F}from"../../settings/index.js";import{Box as n}from"../../common/index.js";import{FieldsGroupHeader as x}from"../../common/components/Headers.js";import{SectionHeader as I}from"../../common/components/SectionHeader.js";import{Annotation as b,FieldList as S,FieldView as k,GroupTypeList as M,ReferenceList as R,RequiresScopesButton as H}from"../components/index.js";function L({name:i}){const o=y(),{markdown:p}=F(),{useTranslate:m}=u(),{translate:a}=m(),{type:e,references:s}=f(()=>({type:o?.getType(i),references:o?.getTypeReferences(i)}),[i,o]);return T(e)?r(n,{"data-testid":e.name,direction:"row",wrap:"wrap",gap:"64px",children:[r(g,{"data-testid":"object-item",children:[t(I,{name:e.name,splitWbr:!0}),t(b,{"data-testid":"object-description",children:t(j,{rawMarkdown:e.description,parser:p?.parser})}),t(H,{type:e,isItem:!0}),Object.values(e.getFields()).length?t(n,{direction:"column",wrap:"wrap",children:t(S,{fields:Object.values(e.getFields()),renderField:c=>t(k,{...c,parentType:e})})}):null,!d(e)&&e.getInterfaces().length?r(n,{direction:"column",children:[t(x,{"data-testid":"implements-interfaces",children:a("graphql.implementedInterfaces","Implements interfaces")}),t(M,{types:e.getInterfaces()})]}):null]}),r(h,{"data-testid":"right-section",children:[t(w,{type:e}),s?.length?t(R,{references:s}):null]})]}):null}const J=l(L);export{J as FieldsTypeItem};