-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
104 additions
and
21 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
64 changes: 64 additions & 0 deletions
64
...ages/altair-app/src/app/modules/altair/services/gql/__snapshots__/fillFields.spec.ts.snap
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,64 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`fillAllFields generates expected query 1`] = ` | ||
{ | ||
"insertions": [ | ||
{ | ||
"index": 20, | ||
"string": " { | ||
id | ||
url | ||
name | ||
authors | ||
characters { | ||
id | ||
book | ||
url | ||
name | ||
gender | ||
culture | ||
born | ||
died | ||
titles | ||
aliases | ||
father | ||
mother | ||
spouse | ||
allegiances | ||
books | ||
playedBy | ||
} | ||
released | ||
}", | ||
}, | ||
], | ||
"result": "{ | ||
hello | ||
GOTBooks { | ||
id | ||
url | ||
name | ||
authors | ||
characters { | ||
id | ||
book | ||
url | ||
name | ||
gender | ||
culture | ||
born | ||
died | ||
titles | ||
aliases | ||
father | ||
mother | ||
spouse | ||
allegiances | ||
books | ||
playedBy | ||
} | ||
released | ||
} | ||
}", | ||
} | ||
`; |
22 changes: 22 additions & 0 deletions
22
packages/altair-app/src/app/modules/altair/services/gql/fillFields.spec.ts
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,22 @@ | ||
import { Position } from 'cm6-graphql'; | ||
import { ContextToken, getTokenAtPosition } from 'graphql-language-service'; | ||
import { fillAllFields } from './fillFields'; | ||
import { getTestSchema } from './test-helper'; | ||
|
||
const testQuery = `{ | ||
hello | ||
GOTBooks { | ||
} | ||
}`; | ||
describe('fillAllFields', () => { | ||
it('generates expected query', () => { | ||
const schema = getTestSchema(); | ||
const pos = new Position(2, 12); | ||
const token = getTokenAtPosition(testQuery, pos, 1); | ||
// expect(token).toBe(''); | ||
const res = fillAllFields(schema, testQuery, pos, token, { | ||
maxDepth: 2, | ||
}); | ||
expect(res).toMatchSnapshot(); | ||
}); | ||
}); |
1 change: 0 additions & 1 deletion
1
packages/altair-app/src/app/modules/altair/services/gql/fillFields.ts
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
11 changes: 11 additions & 0 deletions
11
packages/altair-app/src/app/modules/altair/services/gql/test-helper.ts
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,11 @@ | ||
import { readFileSync } from 'fs'; | ||
import { buildSchema } from 'graphql'; | ||
import { resolve } from 'path'; | ||
|
||
export const getTestSchema = () => { | ||
const sdl = readFileSync( | ||
resolve(__dirname, '../../../../../../fixtures/test.sdl'), | ||
'utf8' | ||
); | ||
return buildSchema(sdl); | ||
}; |
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