@redocly/graphql-docs
Version:
Redocly GraphQL docs
2 lines (1 loc) • 1.95 kB
JavaScript
var q=Object.create;var o=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var O=(e,a)=>{for(var t in a)o(e,t,{get:a[t],enumerable:!0})},p=(e,a,t,n)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of f(a))!v.call(e,l)&&l!==t&&o(e,l,{get:()=>a[l],enumerable:!(n=S(a,l))||n.enumerable});return e};var V=(e,a,t)=>(t=e!=null?q(y(e)):{},p(a||!e||!e.__esModule?o(t,"default",{value:e,enumerable:!0}):t,e)),A=e=>p(o({},"__esModule",{value:!0}),e);var k={};O(k,{OperationRequestExample:()=>N});module.exports=A(k);var r=V(require("react")),c=require("@redocly/theme"),u=require("../../settings"),d=require("../../definition/components/CodePanel"),i=require("../operation"),s=require("./styled");const I={query:"Query",mutation:"Mutation",subscription:"Subscription"};function N({operation:e,operationType:a}){const{jsonSamplesDepth:t,samplesMaxInlineArgs:n}=(0,u.useSettings)(),{useTranslate:l}=(0,c.useThemeHooks)(),{translate:m}=l(),g=e.args.length>n,x=(0,i.getOperationExample)({operationType:a,operation:e,expandLevel:t,multilineArguments:g,translate:m}),h=(0,i.getOperationVariablesExample)({args:e.args,expandLevel:t}),E=e.args.length>0,b={query:"graphql.querySample",mutation:"graphql.mutationSample",subscription:"graphql.subscriptionSample"};return r.default.createElement(d.CodePanel,{className:"panel-response-samples",header:m(b[a],`${I[a]} sample`),isExpandable:!1,expanded:!0,$spacing:"xxl"},r.default.createElement(s.StyledCodeBlock,{lang:"graphql",source:x,dataTestId:"query-sample",header:{className:"code-block-header",controls:{copy:{}}}}),E?r.default.createElement(s.VariablesContainer,null,r.default.createElement(s.StyledJsonViewer,{data:h,expandLevel:1/0,title:r.default.createElement(s.SectionHeader,{"data-testid":"vars-title"},m("graphql.variables","Variables"))})):null)}0&&(module.exports={OperationRequestExample});