import { parse } from "graphql" ; import type { DocumentNode } from "graphql" ; import invariant from "invariant" ; note example param strings export function graphql ( document , ... fragments ) { invariant ( document . map ( ( s ) => s . trim ( ) ) . filter ( ( s ) => s . length > 0 ) . length === 1 , "Interpolations are only allowed at the end of the template." ) ; const documentNode = parse ( document [ 0 ] ) ; const definitions = new Set ( documentNode . definitions ) ; fragments . forEach ( ( doc ) => doc . definitions . forEach ( ( def ) => definitions . add ( def ) ) ) ; return { kind : "Document" , definitions : Array . from ( definitions ) } ; }