PageSourceSearch

https://graphql.org/_next/static/chunks/pages/graphql-js/utilities-cc3b022d1570af78.js

js graphql.org collected 2026-09-24 07:01:43 UTC 29,606 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4638],{73892:function(i,s,e){(window.__NEXT_P=window.__NEXT_P||[]).push(["/graphql-js/utilities",function(){return e(49915)}])},49915:function(i,s,e){"use strict";e.r(s),e.d(s,{useTOC:function(){return t}});var h=e(52676),n=e(92937),l=e(45043),a=e(79428),r=e(41751);function t(i){let s={code:"code",...(0,a.a)()};return[{value:"Overview",id:"overview",depth:2},{value:"Introspection",id:"introspection",depth:3},{value:"Schema Language",id:"schema-language",depth:3},{value:"Visitors",id:"visitors",depth:3},{value:"Value Validation",id:"value-validation",depth:3},{value:"Introspection",id:"introspection-1",depth:2},{value:"introspectionQuery",id:"introspectionquery",depth:3},{value:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.code,{children:"buildClientSchema"})}),id:"buildclientschema",depth:3},{value:"Schema Representation",id:"schema-representation",depth:2},{value:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.code,{children:"buildSchema"})}),id:"buildschema",depth:3},{value:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.code,{children:"printSchema"})}),id:"printschema",depth:3},{value:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.code,{children:"printIntrospectionSchema"})}),id:"printintrospectionschema",depth:3},{value:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.code,{children:"buildASTSchema"})}),id:"buildastschema",depth:3},{value:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.code,{children:"typeFromAST"})}),id:"typefromast",depth:3},{value:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.code,{children:"astFromValue"})}),id:"astfromvalue",depth:3},{value:"Visitors",id:"visitors-1",depth:2},{value:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.code,{children:"TypeInfo"})}),id:"typeinfo",depth:3},{value:"Value Validation",id:"value-validation-1",depth:2},{value:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.code,{children:"isValidJSValue"})}),id:"isvalidjsvalue",depth:3},{value:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.code,{children:"isValidLiteralValue"})}),id:"isvalidliteralvalue",depth:3}]}s.default=(0,n.c)(function(i){let{toc:s=t(i)}=i,e={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",p:"p",pre:"pre",span:"span",...(0,a.a)(),...i.components};return(0,h.jsxs)(h.Fragment,{children:["\n",(0,h.jsx)(e.h1,{children:(0,h.jsx)(e.code,{children:"graphql/utilities"})}),"\n",(0,h.jsxs)(e.p,{children:["The ",(0,h.jsx)(e.code,{children:"graphql/utilities"})," module contains common useful computations to use with\nthe GraphQL language and type objects. You can import either from the ",(0,h.jsx)(e.code,{children:"graphql/utilities"})," module, or from the root ",(0,h.jsx)(e.code,{children:"graphql"})," module. For example:"]}),"\n",(0,h.jsx)(e.pre,{icon:r.Dr,tabIndex:"0","data-language":"js","data-word-wrap":"",children:(0,h.jsxs)(e.code,{children:[(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#C2F653"},children:"import"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:" {"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#E1E4E8"},children:" introspectionQuery"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:" }"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#C2F653"},children:" from"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#9ECBFF"},children:' "'}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#609A06","--shiki-dark":"#9ECBFF"},children:"graphql"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#9ECBFF"},children:'"'}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#9FA88A","--shiki-light-font-style":"italic","--shiki-dark":"#737373","--shiki-dark-font-style":"inherit"},children:" // ES6"})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#F97583"},children:"var"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:" {"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#E1E4E8"},children:" introspectionQuery"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:" }"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:" ="}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" require"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#CFD3C5"},children:"("}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#9ECBFF"},children:'"'}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#609A06","--shiki-dark":"#9ECBFF"},children:"graphql"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#9ECBFF"},children:'"'}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#CFD3C5"},children:") "}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#9FA88A","--shiki-light-font-style":"italic","--shiki-dark":"#737373","--shiki-dark-font-style":"inherit"},children:"// CommonJS"})]})]})}),"\n",(0,h.jsx)(e.h2,{id:s[0].id,children:s[0].value}),"\n",(0,h.jsx)(e.h3,{id:s[1].id,children:s[1].value}),"\n",(0,h.jsxs)("ul",{className:"apiIndex",children:[(0,h.jsx)("li",{children:(0,h.jsx)("a",{href:"#introspectionquery",children:(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.code,{children:"var introspectionQuery"})," A GraphQL introspection query containing enough information to reproduce a type system."]})})}),(0,h.jsx)("li",{children:(0,h.jsx)("a",{href:"#buildclientschema",children:(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.code,{children:"function buildClientSchema"})," Produces a client schema given the result of querying a schema with ",(0,h.jsx)(e.code,{children:"introspectionQuery"}),"."]})})})]}),"\n",(0,h.jsx)(e.h3,{id:s[2].id,children:s[2].value}),"\n",(0,h.jsxs)("ul",{className:"apiIndex",children:[(0,h.jsx)("li",{children:(0,h.jsx)("a",{href:"#buildschema",children:(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.code,{children:"function buildSchema"})," Builds a Schema object from GraphQL schema language."]})})}),(0,h.jsx)("li",{children:(0,h.jsx)("a",{href:"#printschema",children:(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.code,{children:"function printSchema"})," Prints the schema in a standard format."]})})}),(0,h.jsx)("li",{children:(0,h.jsx)("a",{href:"#printintrospectionschema",children:(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.code,{children:"function printIntrospectionSchema"})," Prints the introspection features of the schema in a standard format."]})})}),(0,h.jsx)("li",{children:(0,h.jsx)("a",{href:"#buildastschema",children:(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.code,{children:"function buildASTSchema"}),"Builds a schema from a parsed AST Schema."]})})}),(0,h.jsx)("li",{children:(0,h.jsx)("a",{href:"#typefromast",children:(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.code,{children:"function typeFromAST"})," Looks up a type referenced in an AST in the GraphQLSchema."]})})}),(0,h.jsx)("li",{children:(0,h.jsx)("a",{href:"#astfromvalue",children:(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.code,{children:"function astFromValue"})," Produces a GraphQL Input Value AST given a JavaScript value."]})})})]}),"\n",(0,h.jsx)(e.h3,{id:s[3].id,children:s[3].value}),"\n",(0,h.jsx)("ul",{className:"apiIndex",children:(0,h.jsx)("li",{children:(0,h.jsx)("a",{href:"#typeinfo",children:(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.code,{children:"class TypeInfo"})," Tracks type and field definitions during a visitor AST traversal.."]})})})}),"\n",(0,h.jsx)(e.h3,{id:s[4].id,children:s[4].value}),"\n",(0,h.jsxs)("ul",{className:"apiIndex",children:[(0,h.jsx)("li",{children:(0,h.jsx)("a",{href:"#isvali
1djsvalue",children:(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.code,{children:"function isValidJSValue"})," Determines if a JavaScript value is valid for a GraphQL type."]})})}),(0,h.jsx)("li",{children:(0,h.jsx)("a",{href:"#isvalidliteralvalue",children:(0,h.jsxs)(e.p,{children:[(0,h.jsx)(e.code,{children:"function isValidLiteralValue"})," Determines if a literal value from an AST is valid for a GraphQL type."]})})})]}),"\n",(0,h.jsx)(e.h2,{id:s[5].id,children:s[5].value}),"\n",(0,h.jsx)(e.h3,{id:s[6].id,children:s[6].value}),"\n",(0,h.jsx)(e.pre,{icon:r.Dr,tabIndex:"0","data-language":"js","data-word-wrap":"",children:(0,h.jsx)(e.code,{children:(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#F97583"},children:"const"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#1976D2","--shiki-dark":"#79B8FF"},children:" introspectionQuery"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:" ="}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#9ECBFF"},children:" `"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#609A06","--shiki-dark":"#9ECBFF"},children:"..."}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#9ECBFF"},children:"`"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:";"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#9FA88A","--shiki-light-font-style":"italic","--shiki-dark":"#737373","--shiki-dark-font-style":"inherit"},children:" // a GraphQL introspection query string"})]})})}),"\n",(0,h.jsx)(e.p,{children:"A GraphQL query that queries a server’s introspection system for enough\ninformation to reproduce that server’s type system."}),"\n",(0,h.jsx)(e.h3,{id:s[7].id,children:s[7].value}),"\n",(0,h.jsx)(e.pre,{icon:r.KP,tabIndex:"0","data-language":"ts","data-word-wrap":"",children:(0,h.jsxs)(e.code,{children:[(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#F97583"},children:"function"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" buildClientSchema"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"("})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:"  introspection"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" IntrospectionQuery"})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:")"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLSchema"})]})]})}),"\n",(0,h.jsx)(e.p,{children:"Build a GraphQLSchema for use by client tools."}),"\n",(0,h.jsx)(e.p,{children:"Given the result of a client running the introspection query, creates and\nreturns a GraphQLSchema instance which can be then used with all GraphQL.js\ntools, but cannot be used to execute a query, as introspection does not\nrepresent the “resolver”, “parse” or “serialize” functions or any other\nserver-internal mechanisms."}),"\n",(0,h.jsx)(e.h2,{id:s[8].id,children:s[8].value}),"\n",(0,h.jsx)(e.h3,{id:s[9].id,children:s[9].value}),"\n",(0,h.jsx)(e.pre,{icon:r.KP,tabIndex:"0","data-language":"ts","data-word-wrap":"",children:(0,h.jsx)(e.code,{children:(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#F97583"},children:"function"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" buildSchema"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"("}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:"source"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#1976D2","--shiki-dark":"#FF99E0"},children:" string"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:" |"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" Source"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:")"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLSchema"})]})})}),"\n",(0,h.jsxs)(e.p,{children:["Creates a GraphQLSchema object from GraphQL schema language. The schema will use default resolvers. For more detail on the GraphQL schema language, see the ",(0,h.jsx)(e.a,{href:"/learn/schema/",children:"schema language docs"})," or this ",(0,h.jsx)(e.a,{href:"https://wehavefaces.net/graphql-sh
1orthand-notation-cheatsheet-17cd715861b6#.9oztv0a7n",children:"schema language cheat sheet"}),"."]}),"\n",(0,h.jsx)(e.h3,{id:s[10].id,children:s[10].value}),"\n",(0,h.jsx)(e.pre,{icon:r.KP,tabIndex:"0","data-language":"ts","data-word-wrap":"",children:(0,h.jsx)(e.code,{children:(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#F97583"},children:"function"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" printSchema"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"("}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:"schema"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLSchema"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:")"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#1976D2","--shiki-dark":"#FF99E0"},children:" string"})]})})}),"\n",(0,h.jsx)(e.p,{children:"Prints the provided schema in the Schema Language format."}),"\n",(0,h.jsx)(e.h3,{id:s[11].id,children:s[11].value}),"\n",(0,h.jsx)(e.pre,{icon:r.KP,tabIndex:"0","data-language":"ts","data-word-wrap":"",children:(0,h.jsx)(e.code,{children:(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#F97583"},children:"function"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" printIntrospectionSchema"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"("}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:"schema"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLSchema"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:")"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#1976D2","--shiki-dark":"#FF99E0"},children:" string"})]})})}),"\n",(0,h.jsx)(e.p,{children:"Prints the built-in introspection schema in the Schema Language format."}),"\n",(0,h.jsx)(e.h3,{id:s[12].id,children:s[12].value}),"\n",(0,h.jsx)(e.pre,{icon:r.KP,tabIndex:"0","data-language":"ts","data-word-wrap":"",children:(0,h.jsxs)(e.code,{children:[(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#F97583"},children:"function"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" buildASTSchema"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"("})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:"  ast"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" SchemaDocument"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:","})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:"  queryTypeName"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#1976D2","--shiki-dark":"#FF99E0"},children:" string"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:","})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:"  mutationTypeName"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#1976D2","--shiki-dark":"#FF99E0"},children:" string"})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:")"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLSchema"})]})]})}),"\n",(0,h.jsxs)(e.p,{children:["This takes the ast of a schema document produced by ",(0,h.jsx)(e.code,{children:"parseSchemaIntoAST"})," in\n",(0,h.jsx)(e.code,{children:"graphql/language/schema"})," and constructs a GraphQLSchema instance which can be\nthen used with all GraphQL.js tools, but cannot be used to execute a query, as\nintrospection does not represent the “resolver”, “parse” or “serialize”\nfunctions or any other server-internal mechanisms."]}),"\n",(0,h.jsx)(e.h3,{id:s[13].id,children:s[13].value}),"\n",(0,h.jsx)(e.pre,{icon:r.KP,tabIndex:"0","data-language":"ts","data-word-wrap":"",children:(0,h.jsxs)(e.code,{children:[(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#F97583"},children:"function"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" typeFromAST"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"("})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:"  schema"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLSchema"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:","})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:"  inputTypeAST"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" Type"})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:")"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLType"})]})]})}),"\n",(0,h.jsx)(e.p,{children:"Given the name of a Type as it appears in a GraphQL AST and a Schema, return the\ncorresponding GraphQLType from that schema."}),"\n",(0,h.jsx)(e.h3,{id:s[14].id,children:s[14].value}),"\n",(0,h.jsx)(e.pre,{icon:r.KP,tabIndex:"0","data-language":"ts","data-word-wrap":"",children:(0,h.jsxs)(e.code,{children:[(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#F97583"},children:"function"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" astFromValue"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"("})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:"  value"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#1976D2","--shiki-dark":"#FF99E0"},children:" any"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:","})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:"  type"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLInputType"})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:")"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" Value"})]})]})}),"\n",(0,h.jsx)(e.p,{children:"Produces a GraphQL Input Value AST given a JavaScript value."}),"\n",(0,h.jsx)(e.p,{children:"Optionally, a GraphQL type may be provided, which will be used to\ndisambiguate between value primitives."}),"\n",(0,h.jsx)(e.h2,{id:s[15].id,children:s[15].value}),"\n",(0,h.jsx)(e.h3,{id:s[16].id,children:s[16].value}),"\n",(0,h.jsx)(e.pre,{icon:r.KP,tabIndex:"0","data-language":"ts","data-word-wrap":"",children:(0,h.jsxs)(e.code,{children:[(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#F97583"},children:"class"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" TypeInfo"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:" {"})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#F97583"},children:"  constructor"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"("}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:"schema"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLSchema"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:")"})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:"  getType"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"}
1,children:"()"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLOutputType"})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:"  getParentType"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"()"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLCompositeType"})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:"  getInputType"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"()"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLInputType"})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:"  getFieldDef"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"()"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLFieldDefinition"})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:"  getDirective"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"()"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLDirective"})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:"  getArgument"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"()"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLArgument"})]}),"\n",(0,h.jsx)(e.span,{children:(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"}"})})]})}),"\n",(0,h.jsxs)(e.p,{children:["TypeInfo is a utility class which, given a GraphQL schema, can keep track\nof the current field and type definitions at any point in a GraphQL document\nAST during a recursive descent by calling ",(0,h.jsx)(e.code,{children:"enter(node)"})," and ",(0,h.jsx)(e.code,{children:"leave(node)"}),"."]}),"\n",(0,h.jsx)(e.h2,{id:s[17].id,children:s[17].value}),"\n",(0,h.jsx)(e.h3,{id:s[18].id,children:s[18].value}),"\n",(0,h.jsx)(e.pre,{icon:r.KP,tabIndex:"0","data-language":"ts","data-word-wrap":"",children:(0,h.jsx)(e.code,{children:(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#F97583"},children:"function"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" isValidJSValue"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"("}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:"value"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#1976D2","--shiki-dark":"#FF99E0"},children:" any"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:","}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:" type"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLInputType"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:")"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#1976D2","--shiki-dark":"#FF99E0"},children:" string"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#CFD3C5"},children:"[]"})]})})}),"\n",(0,h.jsx)(e.p,{children:"Given a JavaScript value and a GraphQL type, determine if the value will be\naccepted for that type. This is primarily useful for validating the\nruntime values of query variables."}),"\n",(0,h.jsx)(e.h3,{id:s[19].id,children:s[19].value}),"\n",(0,h.jsx)(e.pre,{icon:r.KP,tabIndex:"0","data-language":"ts","data-word-wrap":"",children:(0,h.jsxs)(e.code,{children:[(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#F97583"},children:"function"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" isValidLiteralValue"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:"("})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:"  type"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" GraphQLInputType"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:","})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#DBF6A2"},children:"  valueAST"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#0E0F0B","--shiki-dark":"#F3F4F0"},children:" Value"})]}),"\n",(0,h.jsxs)(e.span,{children:[(0,h.jsx)(e.span,{style:{"--shiki-light":"#6E7557","--shiki-dark":"#6E7557"},children:")"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#E10198","--shiki-dark":"#ECFAD1"},children:":"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#1976D2","--shiki-dark":"#FF99E0"},children:" string"}),(0,h.jsx)(e.span,{style:{"--shiki-light":"#24292EFF","--shiki-dark":"#CFD3C5"},children:"[]"})]})]})}),"\n",(0,h.jsx)(e.p,{children:"Utility for validators which determines if a value literal AST is valid given\nan input type."}),"\n",(0,h.jsx)(e.p,{children:"Note that this only validates literal values, variables are assumed to\nprovide values of the correct type."})]})},"/graphql-js/utilities",{filePath:"src/pages/graphql-js/utilities.mdx",timestamp:1789481543e3,pageMap:l.v,frontMatter:{title:"graphql/utilities"},title:"graphql/utilities"},"undefined"==typeof RemoteContent?t:RemoteContent.useTOC)}},function(i){i.O(0,[3556,5043,2888,9774,179],function(){return i(i.s=73892)}),_N_E=i.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.