Skip to content

Commit 3fa4504

Browse files
authored
Merge pull request #244 from proto-graphql/izumin5210/import-from-same-pkg
Add test for importing types from the same package
2 parents 4817b73 + 3a77c7f commit 3fa4504

File tree

24 files changed

+732
-2
lines changed

24 files changed

+732
-2
lines changed

e2e/tests.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"tests": [
33
{ "target": "nexus", "proto": { "package": "deprecation", "lib": "google-protobuf" } },
44
{ "target": "nexus", "proto": { "package": "deprecation", "lib": "protobufjs" } },
5+
{ "target": "nexus", "proto": { "package": "edgecases/import_from_same_pkg", "lib": "google-protobuf" } },
6+
{ "target": "nexus", "proto": { "package": "edgecases/import_from_same_pkg", "lib": "protobufjs" } },
57
{ "target": "nexus", "proto": { "package": "edgecases/import_squashed_union", "lib": "google-protobuf" } },
68
{ "target": "nexus", "proto": { "package": "edgecases/import_squashed_union", "lib": "protobufjs" } },
79
{ "target": "nexus", "proto": { "package": "empty_types", "lib": "google-protobuf" } },
@@ -23,6 +25,7 @@
2325
{ "target": "nexus", "proto": { "package": "wktypes", "lib": "google-protobuf" } },
2426
{ "target": "nexus", "proto": { "package": "wktypes", "lib": "protobufjs" } },
2527
{ "target": "pothos", "proto": { "package": "deprecation", "lib": "ts-proto" } },
28+
{ "target": "pothos", "proto": { "package": "edgecases/import_from_same_pkg", "lib": "ts-proto" } },
2629
{ "target": "pothos", "proto": { "package": "edgecases/import_squashed_union", "lib": "ts-proto" } },
2730
{ "target": "pothos", "proto": { "package": "empty_types", "lib": "ts-proto" } },
2831
{ "target": "pothos", "proto": { "package": "enums", "lib": "ts-proto" } },

e2e/tests/nexus--edgecases-import_from_same_pkg--google-protobuf/__generated__/schema.graphql

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { ParentMessage } from "@testapis/node-native/lib/testapis/edgecases/import_from_same_pkg/parent_pb";
2+
import { queryField } from "nexus";
3+
import { makeTestSchema } from "../../src/makeTestSchema";
4+
import * as parentTypes from "../__generated__/nexus/google-protobuf/testapis/edgecases/import_from_same_pkg/parent_pb_nexus";
5+
import * as childTypes from "../__generated__/nexus/google-protobuf/testapis/edgecases/import_from_same_pkg/child_pb_nexus";
6+
7+
const testQuery = queryField("test1", {
8+
type: "ParentMessage",
9+
resolve() {
10+
return new ParentMessage();
11+
},
12+
});
13+
14+
export const schema = makeTestSchema({ rootDir: __dirname, types: [parentTypes, childTypes, testQuery] });
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Code generated by setupTests.mjs. DO NOT EDIT.
2+
{
3+
"extends": "../../tsconfig.base.json",
4+
"compilerOptions": {
5+
"baseUrl": ".",
6+
"paths": {
7+
"@testapp/*": ["./*"]
8+
}
9+
},
10+
"include": [
11+
"./**/*",
12+
"../../src/**/*",
13+
"../__generated__/nexus/google-protobuf/testapis/edgecases/import_from_same_pkg/**/*"
14+
]
15+
}

e2e/tests/nexus--edgecases-import_from_same_pkg--protobufjs/__generated__/schema.graphql

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as pbjs from "@testapis/node/lib/testapis/edgecases/import_from_same_pkg";
2+
import { queryField } from "nexus";
3+
import { makeTestSchema } from "../../src/makeTestSchema";
4+
import * as parentTypes from "../__generated__/nexus/protobufjs/testapis/edgecases/import_from_same_pkg/parent_pb_nexus";
5+
import * as childTypes from "../__generated__/nexus/protobufjs/testapis/edgecases/import_from_same_pkg/child_pb_nexus";
6+
7+
const testQuery = queryField("test1", {
8+
type: "ParentMessage",
9+
resolve() {
10+
return new pbjs.testapis.edgecases.import_from_same_pkg.ParentMessage();
11+
},
12+
});
13+
14+
export const schema = makeTestSchema({ rootDir: __dirname, types: [parentTypes, childTypes, testQuery] });
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Code generated by setupTests.mjs. DO NOT EDIT.
2+
{
3+
"extends": "../../tsconfig.base.json",
4+
"compilerOptions": {
5+
"baseUrl": ".",
6+
"paths": {
7+
"@testapp/*": ["./*"]
8+
}
9+
},
10+
"include": [
11+
"./**/*",
12+
"../../src/**/*",
13+
"../__generated__/nexus/protobufjs/testapis/edgecases/import_from_same_pkg/**/*"
14+
]
15+
}

e2e/tests/pothos--edgecases-import_from_same_pkg--ts-proto/__generated__/schema.graphql

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import SchemaBuilder from "@pothos/core";
2+
3+
export const builder = new SchemaBuilder({});
4+
builder.queryType({});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { graphql } from "graphql";
2+
import { schema } from "./schema";
3+
4+
it("processes a query successfully", async () => {
5+
const resp = await graphql(
6+
schema,
7+
/* GraphQL */ `
8+
query Test {
9+
test {
10+
child {
11+
body
12+
}
13+
}
14+
}
15+
`
16+
);
17+
expect(resp).toMatchInlineSnapshot(`
18+
Object {
19+
"data": Object {
20+
"test": Object {
21+
"child": Object {
22+
"body": "hello",
23+
},
24+
},
25+
},
26+
}
27+
`);
28+
});

0 commit comments

Comments
 (0)