-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export missing exports for apollo-client
- Loading branch information
1 parent
0e92930
commit 4e03ea5
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@0no-co/graphql.web': patch | ||
--- | ||
|
||
Add missing exports to make apollo-client functional with this library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
|
||
import { parse } from '../parser'; | ||
import { isSelectionNode, Source } from '../helpers'; | ||
import type { OperationDefinitionNode } from '../ast'; | ||
|
||
describe('helpers', () => { | ||
it('Correctly indicates a selection-node', () => { | ||
const parsed = parse(` | ||
query { | ||
field | ||
... on Query { field } | ||
...Frag | ||
} | ||
fragment Frag on Query { field } | ||
`); | ||
|
||
const operation = parsed.definitions[0] as OperationDefinitionNode; | ||
expect(isSelectionNode(operation.selectionSet.selections[0])).toEqual(true); | ||
expect(isSelectionNode(operation.selectionSet.selections[1])).toEqual(true); | ||
expect(isSelectionNode(operation.selectionSet.selections[2])).toEqual(true); | ||
}); | ||
|
||
it('Source is a function', () => { | ||
expect(typeof Source).toEqual('function'); | ||
expect(Source('test')).toEqual({ | ||
body: 'test', | ||
name: undefined, | ||
locationOffset: { line: 1, column: 1 }, | ||
}); | ||
expect(Source('test', 'test', { line: 2, column: 1 })).toEqual({ | ||
body: 'test', | ||
name: 'test', | ||
locationOffset: { line: 2, column: 1 }, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { Source, Location } from './types'; | ||
import type { ASTNode, SelectionNode } from './ast'; | ||
|
||
export function isSelectionNode(node: ASTNode): node is SelectionNode { | ||
return node.kind === 'Field' || node.kind === 'FragmentSpread' || node.kind === 'InlineFragment'; | ||
} | ||
|
||
export function Source(body: string, name?: string, locationOffset?: Location): Source { | ||
return { | ||
body, | ||
name, | ||
locationOffset: locationOffset || { line: 1, column: 1 }, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters