Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
at main 639 B view raw
1import type { NameNode, GraphQLOutputType, GraphQLWrappingType } from 'graphql'; 2import { isWrappingType, Kind } from 'graphql'; 3 4export type GraphQLFlatType = Exclude<GraphQLOutputType, GraphQLWrappingType>; 5 6/** Returns the name of a given node */ 7export const getName = (node: { name: NameNode }): string => node.name.value; 8 9export const unwrapType = ( 10 type: null | undefined | GraphQLOutputType 11): GraphQLFlatType | null => { 12 if (isWrappingType(type)) { 13 return unwrapType(type.ofType); 14 } 15 16 return type || null; 17}; 18 19export function createNameNode(value: string): NameNode { 20 return { 21 kind: Kind.NAME, 22 value, 23 }; 24}