https://fusedata.dev/_next/static/chunks/pages/docs/server/queries-and-mutations-eb983d80000c83e5.js
1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[455],{9957:function(e,n,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/docs/server/queries-and-mutations",function(){return s(4086)}])},4086:function(e,n,s){"use strict";s.r(n),s.d(n,{__toc:function(){return c}});var t=s(5250),r=s(8720),i=s(5074),o=s(6965);s(664);var a=s(2318),l=s(281);let c=[{depth:2,value:"Arguments",id:"arguments"}];function d(e){let n=Object.assign({h1:"h1",p:"p",code:"code",pre:"pre",span:"span",h2:"h2",ul:"ul",li:"li"},(0,a.a)(),e.components);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h1,{children:"Queries and Mutations"}),"\n",(0,t.jsx)(n.p,{children:"The API consists of entry-points which we will use to fulfill our data-requirements, often\nwhen we start a new page we'll need to either use an existing entry-point or create a new one."}),"\n",(0,t.jsxs)(n.p,{children:["For retrieving data one or more of those entry-points can be created with the ",(0,t.jsx)(n.code,{children:"addQueryFields"})," function."]}),"\n",(0,t.jsx)(n.pre,{"data-language":"typescript","data-theme":"default",children:(0,t.jsxs)(n.code,{"data-language":"typescript","data-theme":"default",children:[(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" { addQueryFields } "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'fuse'"})]}),"\n",(0,t.jsx)(n.span,{className:"line",children:" "}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"addQueryFields"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"(t "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"=>"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" ({"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" me"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"t"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".field"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"({"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" type"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" UserNode"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"resolve"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" (parent"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" args"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" context) "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"=>"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"context"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:".userId"})]}),"\n",(0,t.jsx)(n.span,{className:"line",children:(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" })"})}),"\n",(0,t.jsx)(n.span,{className:"line",children:(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"}))"})})]})}),"\n",(0,t.jsxs)(n.p,{children:["The above could for instance be an entry-point for a ",(0,t.jsx)(n.code,{children:"profile"})," page or any page that has a menu-dropdown\nwelcoming the user."]}),"\n",(0,t.jsxs)(n.p,{children:["Our API should also be able to manipulate data, these are referred to as ",(0,t.jsx)(n.code,{children:"mutations"})," and can be added\nsimilarly to ",(0,t.jsx)(n.code,{children:"query"})," entry-points by means of ",(0,t.jsx)(n.code,{children:"addMutationFields"}),"."]}),"\n",(0,t.jsx)(n.pre,{"data-language":"typescript","data-theme":"default",children:(0,t.jsxs)(n.code,{"data-language":"typescript","data-theme":"default",children:[(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" { addMutationFields } "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'fuse'"})]}),"\n",(0,t.jsx)(n.span,{className:"line",children:" "}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"addMutationFields"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"(t "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"=>"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" ({"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" sayHello"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"t"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".field"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"({"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" type"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'String'"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" args"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" {"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" name"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"t"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"."}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"arg"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".string"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"({ required"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"true"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" })"})]}),"\n",(0,t.jsx)(n.span,{className:"line",children:(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" }"})}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" resolve: (parent"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" args"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" context) "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"=>"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"`Hello "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"${"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"args"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:".name"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"}"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"!`"})]}),"\n",(0,t.jsx)(n.span,{className:"line",children:(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" })"})}),"\n",(0,t.jsx)(n.span,{className:"line",children:(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"}))"})})]})}),"\n",(0,t.jsx)(n.p,{children:"Now we have an entry-point to retrieve our own user and to greet a user!"}),"\n",(0,t.jsx)(n.h2,{id:"arguments",children:(0,t.jsx)(l.K,{children:"Arguments"})}),"\n",(0,t.jsxs)(n.p,{children:["As you can see in the above examples we can define ",(0,t.jsx)(l.K,{children:"arguments"})," for our entry-points, these arguments are optional\nby default and can be made required by means of ",(0,t.jsx)(n.code,{children:"{ required: true }"}),". All scalar values have their own ",(0,t.jsx)(n.code,{children:"t.arg"}),"\nwhich can be used to define arguments on a field. The mention of ",(0,t.jsx)(n.code,{children:"field"}
1)," is important here as arguments\naren't exclusive to ",(0,t.jsx)(n.code,{children:"query"})," and ",(0,t.jsx)(n.code,{children:"mutation"})," entry-points, they can be used on any field. An example of this could\nbe when we ",(0,t.jsx)(n.code,{children:"extend"})," the ",(0,t.jsx)(n.code,{children:"UserNode"})," and want to add a ",(0,t.jsx)(n.code,{children:"friends"})," field to it, we can add ",(0,t.jsx)(n.code,{children:"args"})," there to make the list\nof friends paginated."]}),"\n",(0,t.jsxs)(n.p,{children:["Summing up all the built-in ",(0,t.jsx)(l.K,{term:"arguments",children:"argument scalars"}),":"]}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.code,{children:"id"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.code,{children:"string"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.code,{children:"boolean"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.code,{children:"int"})}),"\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.code,{children:"float"})}),"\n"]}),"\n",(0,t.jsxs)(n.p,{children:["Most of these also have a ",(0,t.jsx)(n.code,{children:"*List"})," equivalent to indicate you will pass an array of that scalar type."]}),"\n",(0,t.jsxs)(n.p,{children:["We won't always be passing in scalar-values and we might even want to re-use certain inputs for multiple fields,\nlike for example a ",(0,t.jsx)(n.code,{children:"PaginationInput"})," which we can use on any field we paginate over. We can do this by importing\n",(0,t.jsx)(n.code,{children:"inputType"})," from ",(0,t.jsx)(n.code,{children:"fuse"})," and creating one as followed"]}),"\n",(0,t.jsx)(n.pre,{"data-language":"typescript","data-theme":"default",children:(0,t.jsxs)(n.code,{"data-language":"typescript","data-theme":"default",children:[(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"import"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" { inputType } "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"from"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'fuse'"})]}),"\n",(0,t.jsx)(n.span,{className:"line",children:" "}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"const"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"PaginationInput"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"="}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"inputType"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"({"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" name"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-string-expression)"},children:"'PaginationInput'"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:"fields"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" (t) "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:"=>"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" ({"})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" offset"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"t"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".int"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"({ defaultValue"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"0"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" })"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" limit"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"t"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-function)"},children:".int"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"({ defaultValue"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-keyword)"},children:":"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" "}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-constant)"},children:"10"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" })"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,t.jsxs)(n.span,{className:"line",children:[(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:" })"}),(0,t.jsx)(n.span,{style:{color:"var(--shiki-token-punctuation)"},children:","})]}),"\n",(0,t.jsx)(n.span,{className:"line",children:(0,t.jsx)(n.span,{style:{color:"var(--shiki-color-text)"},children:"})"})})]})}),"\n",(0,t.jsxs)(n.p,{children:["Now when we want to use ",(0,t.jsx)(n.code,{children:"PaginationInput"})," we can pass it to ",(0,t.jsx)(n.code,{children:"t.arg"}),", for example ",(0,t.jsx)(n.code,{children:"{ pagination: t.arg({ type: PaginationInput }) }"}),"."]}),"\n",(0,t.jsxs)(n.p,{children:["Now we can pass this input to our ",(0,t.jsx)(n.code,{children:"fields"})," accepting these ",(0,t.jsx)(l.K,{children:"arguments"}),"!"]})]})}let h={MDXContent:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{wrapper:n}=Object.assign({},(0,a.a)(),e.components);return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(d,{...e})}):d(e)},pageOpts:{filePath:"src/pages/docs/server/queries-and-mutations.mdx",route:"/docs/server/queries-and-mutations",pageMap:[{kind:"Meta",data:{index:{type:"page",title:"Fuse",dis
1play:"hidden",theme:{layout:"full"}},docs:{type:"page",display:"hidden",title:"Documentation"}}},{kind:"Folder",name:"docs",route:"/docs",children:[{kind:"Meta",data:{index:"Getting Started",client:"Querying your API (client)",server:"Building your API (server)",deployment:"Deploying your API (server)","fuse-method":"The Fuse Method","setting-fuse-up-manually":"Setting up Fuse manually",troubleshooting:"Troubleshooting"}},{kind:"Folder",name:"client",route:"/docs/client",children:[{kind:"Meta",data:{index:"Overview","best-practices":"Best practices",types:"Types",javascript:"JavaScript frameworks",other:"Other languages"}},{kind:"MdxPage",name:"best-practices",route:"/docs/client/best-practices"},{kind:"MdxPage",name:"index",route:"/docs/client"},{kind:"Folder",name:"javascript",route:"/docs/client/javascript",children:[{kind:"Meta",data:{react:"React & React Native",nextjs:"Next.js",vue:"Vue",angular:"Angular"}},{kind:"MdxPage",name:"angular",route:"/docs/client/javascript/angular"},{kind:"MdxPage",name:"nextjs",route:"/docs/client/javascript/nextjs"},{kind:"MdxPage",name:"react",route:"/docs/client/javascript/react"},{kind:"MdxPage",name:"vue",route:"/docs/client/javascript/vue"}]},{kind:"Folder",name:"other",route:"/docs/client/other",children:[{kind:"Meta",data:{ios:"iOS",android:"Android (Java/Kotlin)",http:"HTTP"}},{kind:"MdxPage",name:"android",route:"/docs/client/other/android"},{kind:"MdxPage",name:"http",route:"/docs/client/other/http"},{kind:"MdxPage",name:"ios",route:"/docs/client/other/ios"}]},{kind:"MdxPage",name:"types",route:"/docs/client/types"}]},{kind:"Folder",name:"deployment",route:"/docs/deployment",children:[{kind:"Meta",data:{index:"Overview",node:"Node.js",lambda:"Lambda","cloudflare-workers":"Cloudflare Workers",nextjs:"Next.js API Routes",bun:"Bun"}},{kind:"MdxPage",name:"bun",route:"/docs/deployment/bun"},{kind:"MdxPage",name:"cloudflare-workers",route:"/docs/deployment/cloudflare-workers"},{kind:"MdxPage",name:"index",route:"/docs/deployment"},{kind:"MdxPage",name:"lambda",route:"/docs/deployment/lambda"},{kind:"MdxPage",name:"nextjs",route:"/docs/deployment/nextjs"},{kind:"MdxPage",name:"node",route:"/docs/deployment/node"}]},{kind:"Folder",name:"fuse-method",route:"/docs/fuse-method",children:[{kind:"Meta",data:{index:"Overview","vs-backend-for-frontends":"vs. Backend-for-Frontends","vs-graphql-federation":"vs. GraphQL Federation"}},{kind:"MdxPage",name:"index",route:"/docs/fuse-method"},{kind:"MdxPage",name:"vs-backend-for-frontends",route:"/docs/fuse-method/vs-backend-for-frontends"},{kind:"MdxPage",name:"vs-graphql-federation",route:"/docs/fuse-method/vs-graphql-federation"}]},{kind:"MdxPage",name:"index",route:"/docs"},{kind:"Folder",name:"server",route:"/docs/server",children:[{kind:"Meta",data:{"queries-and-mutations":"Queries and Mutations",nodes:"Nodes",lists:"Handling lists","objects-enums-unions-interfaces":"Objects, Enums, Unions, and Interfaces",context:"Context",integrations:"Integrating data sources","error-handling":"Error handling",authorization:"Authorization",mocking:"Mocking data"}},{kind:"MdxPage",name:"authorization",route:"/docs/server/authorization"},{kind:"MdxPage",name:"context",route:"/docs/server/context"},{kind:"MdxPage",name:"error-handling",route:"/docs/server/error-handling"},{kind:"Folder",name:"integrations",route:"/docs/server/integrations",children:[{kind:"Meta",data:{index:"Overview",rest:"REST",prisma:"Prisma",drizzle:"Drizzle",kysely:"Kysely",grpc:"gRPC"}},{kind:"MdxPage",name:"drizzle",route:"/docs/server/integrations/drizzle"},{kind:"MdxPage",name:"grpc",route:"/docs/server/integrations/grpc"},{kind:"MdxPage",name:"index",route:"/docs/server/integrations"},{kind:"MdxPage",name:"kysely",route:"/docs/server/integrations/kysely"},{kind:"MdxPage",name:"prisma",route:"/docs/server/integrations/prisma"},{kind:"MdxPage",name:"rest",route:"/docs/server/integrations/rest"}]},{kind:"MdxPage",name:"lists",route:"/docs/server/lists"},{kind:"MdxPage",name:"mocking",route:"/docs/server/mocking"},{kind:"MdxPage",name:"nodes",route:"/docs/server/nodes"},{kind:"MdxPage",name:"objects-enums-unions-interfaces",route:"/docs/server/objects-enums-unions-interfaces"},{kind:"MdxPage",name:"queries-and-mutations",route:"/docs/server/queries-and-mutations"}]},{kind:"Folder",name:"setting-fuse-up-manually",route:"/docs/setting-fuse-up-manually",children:[{kind:"Meta",data:{index:"Overview",nextjs:"Next.js Integration"}},{kind:"MdxPage",name:"index",route:"/docs/setting-fuse-up-manually"},{kind:"MdxPage",name:"nextjs",route:"/docs/setting-fuse-up-manually/nextjs"}]},{kind:"MdxPage",name:"troubleshooting",route:"/docs/troubleshooting"}]}],flexsearch:{codeblocks:!0},title:"Queries and Mutations",headings:c},pageNextRoute:"/docs/server/queries-and-mutations",nextraLayout:i.ZP,themeConfig:o.Z};n.default=(0,r.j)(h)},281:function(e,n,s){"use strict";s.d(n,{K:function(){return o}});var t=s(5250),r=s(3762);let i={arguments:(0,t.jsx)(t.Fragment,{children:'An argument is a key-value that can be applied to a field which will affect the result of the field. Examples of this could be user(id: $id) or date(format: "utc").'}),aliases:(0,t.jsx)(t.Fragment,{children:'An alias allows us to rename a field in the response, this is useful when we want to avoid naming collisions or when we want to rename a field to something more meaningful. A practical example of this could be when your field has an argument to convert the data and you want it in two formats i.e. utc: date(format: "utc") and local: date(format: "local").'}),colocation:(0,t.jsx)(t.Fragment,{children:"Co-location means that we put things we use close to where we use them, like in the fuse case we'll put the data-requirements (our fragments) close to the components we write so we can iterate on them quickly."}),nullability:(0,t.jsxs)(t.Fragment,{children:["Nullability in GraphQL means that a field can return ",(0,t.jsx)("code",{children:"null"})," or"," ","a value. This is different from being optional as GraphQL has no notion of"," ",(0,t.jsx)("code",{children:"undefined"}),". When a null value is returned for a non-nullable field then this will bubble the null value up to the first non-nullable parent field."]}),documents:(0,t.jsx)(t.Fragment,{children:"When you write a GraphQL query you are writing a document, the document (also referred to as the executable document) will be presented to the server and be translated into the data you are asking for."}),types:(0,t.jsx)(t.Fragment,{children:"A GraphQL Type is the basic building block of GraphQL, it can be an object/interface defining multiple fields (properties on an entity), it can be a scalar like a string or integer, it can be a given input type, a union of types or an enum of values."}),fields:(0,t.jsx)(t.Fragment,{children:"A field is a piece of data that exists on an object/interface type, they can be queried and represent a scalar value or a relation to other another entity."}),resolvers:(0,t.jsx)(t.Fragment,{children:"A resolver is a piece of logic that accompanies a field, this can allow us to compute a value, rename a property or fetch a related value from a database/..."}),fragments:(0,t.jsx)(t.Fragment,{children:"A fragment is a reusable piece of a query, it can be used to avoid repeating yourself and to co-locate data-requirements with your components. Look at it like a blueprint of a component, given this data this component will visualize it."}),"type-condition":(0,t.jsx)(t.Fragment,{children:"A type-condition allows us to conditionally ask for the fields, this is useful on union types where the fields on the returned types could be inherently different."}),"fragment-spreads":(0,t.jsxs)(t.Fragment,{children:["A fragment-spread is the way to use a fragment, you can recognise it by it looking like ",(0,t.jsx)("code",{children:"...fragment_name"})," and will signal that the fields defined in that fragment will be queried where we spread the fragment."]})};function o(e){let{term:n,children:s}
1=e,o="string"==typeof n?n.toLocaleLowerCase():"string"==typeof s?s.toLowerCase():void 0,a=o?i[o]:void 0;return void 0===a?s:(0,t.jsx)(r.zt,{delayDuration:300,skipDelayDuration:100,children:(0,t.jsxs)(r.fC,{children:[(0,t.jsx)(r.xz,{asChild:!0,children:(0,t.jsx)("span",{className:"cursor-help underline decoration-dashed",tabIndex:0,children:s})}),(0,t.jsx)(r.h_,{children:(0,t.jsx)(r.VY,{sideOffset:5,side:"top",asChild:!0,children:(0,t.jsxs)("div",{className:"tooltip-content relative rounded-[4px] p-0 text-starship-500",children:[(0,t.jsx)("span",{className:"inline-block bg-transparent p-[8px] text-starship-500",children:a}),(0,t.jsx)(r.Eh,{className:"fill-gravel-950"})]})})})]})})}},6965:function(e,n,s){"use strict";var t=s(5250),r=s(5074),i=s(4427),o=s(2218),a=s(7216);let l={logo:(0,t.jsx)(o.L1,{}),primaryHue:88,primarySaturation:{light:50,dark:99},docsRepositoryBase:"https://github.com/StellateHQ/fuse/tree/main/website",useNextSeoProps:()=>({}),head:function(){let{asPath:e}=(0,i.useRouter)(),{frontMatter:n,title:s}=(0,r.ZR)();return(0,a.a)({title:s,url:"https://fusedata.dev"+e,description:n.description})},footer:{text:(0,t.jsxs)("span",{children:["\xa9 ",new Date().getFullYear()," ",(0,t.jsx)("a",{href:"https://stellate.co",target:"_blank",children:"Stellate, Inc"})]})},gitTimestamp:null};n.Z=l}},function(e){e.O(0,[169,417,762,139,774,888,179],function(){return e(e.s=9957)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.