Skip to content

Commit d12d622

Browse files
committed
Add schemaFilePath information to trigger.
1 parent 182bfb0 commit d12d622

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

spec/v2/providers/dataconnect.spec.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,9 @@ describe("dataconnect", () => {
605605
});
606606

607607
describe("onGraphRequest", () => {
608-
it("returns callable function with Data Connect trigger", () => {
608+
it("returns callable function without schemaFilePath Data Connect trigger", () => {
609609
const opts = {
610610
schema: "type Query { hello: String }",
611-
schemaFilePath: "schema.gql",
612611
resolvers: {
613612
query: {
614613
hello: () => "Hello, world!",
@@ -621,11 +620,27 @@ describe("dataconnect", () => {
621620
dataConnectGraphqlTrigger: {},
622621
});
623622
});
623+
it("returns callable function with schemaFilePath Data Connect trigger", () => {
624+
const opts = {
625+
schemaFilePath: "schema.gql",
626+
resolvers: {
627+
query: {
628+
hello: () => "Hello, world!",
629+
},
630+
},
631+
};
632+
const func = dataconnect.onGraphRequest(opts);
633+
expect(func.__endpoint).to.deep.equal({
634+
...expectedEndpointBase,
635+
dataConnectGraphqlTrigger: {
636+
schemaFilePath: "schema.gql",
637+
},
638+
});
639+
});
624640
it("returns callable function with request opts with Data Connect trigger", () => {
625641
const opts = {
626642
invoker: ["test-service-account@test.com"],
627643
region: "us-east4",
628-
schema: "type Query { hello: String }",
629644
schemaFilePath: "schema.gql",
630645
resolvers: {
631646
query: {
@@ -638,6 +653,7 @@ describe("dataconnect", () => {
638653
...expectedEndpointBase,
639654
dataConnectGraphqlTrigger: {
640655
invoker: ["test-service-account@test.com"],
656+
schemaFilePath: "schema.gql",
641657
},
642658
region: ["us-east4"],
643659
});

src/runtime/manifest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export interface ManifestEndpoint {
7373

7474
dataConnectGraphqlTrigger?: {
7575
invoker?: string[];
76+
schemaFilePath?: string;
7677
};
7778

7879
eventTrigger?: {

src/v2/providers/dataconnect.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,9 @@ export function onGraphRequest(opts: GraphqlServerOptions): HttpsFunction {
459459
convertInvoker
460460
);
461461
convertIfPresent(endpoint.dataConnectGraphqlTrigger, opts, "invoker", "invoker", convertInvoker);
462+
if (opts.schemaFilePath) {
463+
endpoint.dataConnectGraphqlTrigger.schemaFilePath = opts.schemaFilePath;
464+
}
462465
(handler as HttpsFunction).__endpoint = endpoint;
463466

464467
return handler as HttpsFunction;

0 commit comments

Comments
 (0)