Skip to content

Commit 3ed367a

Browse files
committed
test wip
1 parent fa15a23 commit 3ed367a

2 files changed

Lines changed: 47 additions & 46 deletions

File tree

packages/apollo-codegen-core/src/compiler/__tests__/index.ts

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,62 +16,61 @@ const schema = loadSchema(
1616
);
1717

1818
fdescribe("Compiling query documents to the legacy IR", () => {
19-
fit(`should include variables defined in operations`, () => {
19+
fit(`should print IR with rawTypes on fields`, () => {
2020
const document = parse(`
2121
query HeroName($episode: Episode) {
2222
hero(episode: $episode) {
2323
name
2424
}
2525
}
2626
27-
query Search($text: String!) {
28-
search(text: $text) {
29-
... on Character {
30-
name
31-
}
32-
}
33-
}
34-
35-
mutation CreateReviewForEpisode($episode: Episode!, $review: ReviewInput!) {
36-
createReview(episode: $episode, review: $review) {
37-
stars
38-
commentary
39-
}
40-
}
41-
`);
4227
43-
const { operations } = withStringifiedTypes(compileToIR(schema, document));
44-
45-
expect(operations["HeroName"].variables).toEqual([
46-
{
47-
name: "episode",
48-
type: "Episode",
49-
rawType: {
50-
kind: "NamedType",
51-
name: {
52-
kind: "Name",
53-
value: "Episode"
54-
}
55-
}
56-
}
57-
]);
58-
59-
// "rawType": Object {
60-
// + "kind": "NamedType",
61-
// + "name": Object {
62-
// + "kind": "Name",
63-
// + "value": "Episode",
64-
// + },
65-
// + },
28+
# query Search($text: String!) {
29+
# search(text: $text) {
30+
# ... on Character {
31+
# name
32+
# }
33+
# }
34+
# }
6635
67-
expect(operations["Search"].variables).toEqual([
68-
{ name: "text", type: "String!" }
69-
]);
36+
# mutation CreateReviewForEpisode($episode: Episode!, $review: ReviewInput!) {
37+
# createReview(episode: $episode, review: $review) {
38+
# stars
39+
# commentary
40+
# }
41+
# }
42+
`);
7043

71-
expect(operations["CreateReviewForEpisode"].variables).toEqual([
72-
{ name: "episode", type: "Episode!" },
73-
{ name: "review", type: "ReviewInput!" }
74-
]);
44+
const { operations } = compileToIR(schema, document);
45+
46+
// console.log(operations);
47+
48+
expect(
49+
operations["HeroName"].selectionSet.selections[0].selectionSet
50+
.selections[0]
51+
).toEqual({});
52+
// expect(operations["HeroName"].variables).toEqual([
53+
// {
54+
// name: "episode",
55+
// type: "Episode",
56+
// rawType: {
57+
// kind: "NamedType",
58+
// name: {
59+
// kind: "Name",
60+
// value: "Episode"
61+
// }
62+
// }
63+
// }
64+
// ]);
65+
66+
// expect(operations["Search"].variables).toEqual([
67+
// { name: "text", type: "String!" }
68+
// ]);
69+
70+
// expect(operations["CreateReviewForEpisode"].variables).toEqual([
71+
// { name: "episode", type: "Episode!" },
72+
// { name: "review", type: "ReviewInput!" }
73+
// ]);
7574
});
7675

7776
it(`should keep track of enums and input object types used in variables`, () => {

packages/apollo-codegen-core/src/compiler/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ class Compiler {
346346
? selectionNode.alias.value
347347
: undefined;
348348

349+
console.log({ schema: this.schema });
349350
const fieldDef = getFieldDef(this.schema, parentType, selectionNode);
350351
if (!fieldDef) {
351352
throw new GraphQLError(
@@ -354,6 +355,7 @@ class Compiler {
354355
);
355356
}
356357

358+
console.log(fieldDef);
357359
const rawType =
358360
fieldDef.astNode && this.options.exposeRawTypes
359361
? stripProp("loc", fieldDef.astNode.type)

0 commit comments

Comments
 (0)