Mirror: The spec-compliant minimum of client-side GraphQL.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Export missing exports for apollo-client (#39)

authored by

Jovi De Croock and committed by
GitHub
8825d164 a5fd37d1

+58
+5
.changeset/yellow-meals-fix.md
··· 1 + --- 2 + '@0no-co/graphql.web': patch 3 + --- 4 + 5 + Add missing exports to make apollo-client functional with this library
+38
src/__tests__/helpers.test.ts
··· 1 + import { describe, it, expect } from 'vitest'; 2 + 3 + import { parse } from '../parser'; 4 + import { isSelectionNode, Source } from '../helpers'; 5 + import type { OperationDefinitionNode } from '../ast'; 6 + 7 + describe('helpers', () => { 8 + it('Correctly indicates a selection-node', () => { 9 + const parsed = parse(` 10 + query { 11 + field 12 + ... on Query { field } 13 + ...Frag 14 + } 15 + 16 + fragment Frag on Query { field } 17 + `); 18 + 19 + const operation = parsed.definitions[0] as OperationDefinitionNode; 20 + expect(isSelectionNode(operation.selectionSet.selections[0])).toEqual(true); 21 + expect(isSelectionNode(operation.selectionSet.selections[1])).toEqual(true); 22 + expect(isSelectionNode(operation.selectionSet.selections[2])).toEqual(true); 23 + }); 24 + 25 + it('Source is a function', () => { 26 + expect(typeof Source).toEqual('function'); 27 + expect(Source('test')).toEqual({ 28 + body: 'test', 29 + name: undefined, 30 + locationOffset: { line: 1, column: 1 }, 31 + }); 32 + expect(Source('test', 'test', { line: 2, column: 1 })).toEqual({ 33 + body: 'test', 34 + name: 'test', 35 + locationOffset: { line: 2, column: 1 }, 36 + }); 37 + }); 38 + });
+14
src/helpers.ts
··· 1 + import type { Location } from './types'; 2 + import type { ASTNode, SelectionNode } from './ast'; 3 + 4 + export function isSelectionNode(node: ASTNode): node is SelectionNode { 5 + return node.kind === 'Field' || node.kind === 'FragmentSpread' || node.kind === 'InlineFragment'; 6 + } 7 + 8 + export function Source(body: string, name?: string, locationOffset?: Location) { 9 + return { 10 + body, 11 + name, 12 + locationOffset: locationOffset || { line: 1, column: 1 }, 13 + }; 14 + }
+1
src/index.ts
··· 8 8 export * from './visitor'; 9 9 export * from './printer'; 10 10 export * from './values'; 11 + export * from './helpers';