UNPKG

@redocly/graphql-docs

Version:

Redocly GraphQL docs

8 lines (7 loc) 2.36 kB
import{jsx as e,jsxs as n,Fragment as f}from"react/jsx-runtime";import{memo as h,useContext as w}from"react";import{useThemeHooks as x,Admonition as T}from"@redocly/theme";import{MiddleSection as R}from"../../app/index.js";import{Markdown as m}from"../../markdown/index.js";import{useSettings as F}from"../../settings/index.js";import{FieldView as p}from"../../definition/components/FieldView.js";import{FieldsGroupHeader as A,StyledItemHeader as k}from"../../common/components/Headers.js";import{Annotation as b}from"./styled.js";import{FieldSummary as j}from"./FieldSummary.js";import{TypeView as S}from"./TypeView.js";import{Arguments as H}from"./Arguments.js";import{toReturnType as M}from"../../schema/index.js";import{ReturnTypeView as s}from"./ReturnTypeView.js";import{PaginationAwareLink as P}from"../../navigation/components/PaginationAwareLink.js";import{useBaseUrlPath as V}from"../../navigation/hooks/use-base-url-path.js";import{joinPath as q}from"../../navigation/utils/join.js";import{MenuStoreContext as I}from"../../menu/index.js";import{ROOT_PATH as _}from"../../navigation/constants.js";import{styled as d}from"../../styled-components.js";import{ArrowIcon as c}from"../../../shared/icons/Arrow.js";import{RequiresScopesButton as B}from"./RequiresScopesButton.js";const C=d(P)` margin-bottom: var(--spacing-xs); display: flex; gap: var(--spacing-unit); `,v=d(A)` margin-bottom: 0; `;function D({field:r,path:u}){const{markdown:a}=F(),{useTranslate:l}=x(),{translate:o}=l(),g=!!r.deprecationReason,t=M(r.type),i=w(I)?.getGroupIdByTypeName(t.name),y=V()||_;return n(R,{"data-testid":"operation-item",children:[e(k,{children:e(j,{field:r,path:u})}),g&&r.deprecationReason&&e(T,{name:o("graphql.deprecationReason","Deprecation reason"),type:"warning",children:e(m,{rawMarkdown:r.deprecationReason,parser:a?.parser})}),r.description&&e(b,{"data-testid":"object-description",children:e(m,{rawMarkdown:r.description,parser:a?.parser})}),e(B,{type:r,isItem:!0}),r.args.length?e(H,{args:r.args,renderField:p,title:o("graphql.arguments.label","Arguments")}):null,e(v,{"data-testid":"return-type-title",children:o("graphql.returnTypes.label","Return type")}),i?n(C,{to:q(y,i,t.name),children:[e(c,{}),e(s,{type:t})]}):n(f,{children:[e(c,{}),e(s,{type:t})]}),e(S,{type:r.type,renderField:p})]})}const pe=h(D);export{pe as ExtendedFieldView};