@redocly/graphql-docs
Version:
Redocly GraphQL docs
2 lines (1 loc) • 1.45 kB
JavaScript
import{jsx as t,jsxs as n}from"react/jsx-runtime";import{memo as d,useMemo as c}from"react";import{isUnionType as l}from"graphql";import{useThemeHooks as u}from"@redocly/theme";import{MiddleSection as f,RightSection as h,useStore as g}from"../../app/index.js";import{Markdown as y}from"../../markdown/index.js";import{useSettings as T}from"../../settings/index.js";import{Box as s}from"../../common/index.js";import{FieldsGroupHeader as w}from"../../common/components/Headers.js";import{SectionHeader as x}from"../../common/components/SectionHeader.js";import{Annotation as S,GroupTypeList as j,ReferenceList as k,RequiresScopesButton as M}from"../components/index.js";function R({name:r}){const o=g(),{markdown:p}=T(),{useTranslate:m}=u(),{translate:a}=m(),{union:e,references:i}=c(()=>({union:o?.getType(r),references:o?.getTypeReferences(r)}),[r,o]);return l(e)?n(s,{"data-testid":e.name,direction:"row",wrap:"wrap",gap:"64px",children:[n(f,{"data-testid":e.name,children:[t(x,{name:e.name}),t(S,{"data-testid":"object-description",children:t(y,{rawMarkdown:e.description,parser:p?.parser})}),t(M,{type:e,isItem:!0}),e.getTypes().length?n(s,{"data-testid":r,direction:"column",children:[t(w,{"data-testid":"return-type-title",children:a("graphql.possibleTypes","Possible types")}),t(j,{types:e.getTypes()})]}):null]}),i?.length?t(h,{"data-testid":"right-section",children:t(k,{references:i})}):null]}):null}const F=d(R);export{F as UnionItem};