Skip to content

Commit 13919e4

Browse files
Merge pull request #20 from dgraph-io/apoorv/info-object
Add info object type
2 parents 6e973d1 + 094a05f commit 13919e4

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

slash-graphql-lambda-types/types.d.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@ declare module "@slash-graphql/lambda-types" {
99
value: string | undefined
1010
}
1111

12+
type InfoField = {
13+
field: selectionField
14+
}
15+
16+
type selectionField = {
17+
alias: string,
18+
name: string,
19+
arguments: Record<string, any>,
20+
directives: fldDirectiveList,
21+
selectionSet: selectionSet
22+
}
23+
24+
type selectionSet = Array<selectionField>
25+
26+
type fldDirectiveList = Array<fldDirective>
27+
28+
type fldDirective = {
29+
name: string,
30+
arguments: Record<string, any>
31+
}
32+
1233
type eventPayload = {
1334
__typename: string,
1435
operation: string,
@@ -45,7 +66,8 @@ declare module "@slash-graphql/lambda-types" {
4566
parents: (Record<string, any>)[] | null,
4667
args: Record<string, any>,
4768
authHeader?: AuthHeaderField,
48-
event?: eventPayload
69+
event?: eventPayload,
70+
info?: InfoField
4971
}
5072

5173
type ResolverResponse = any[] | Promise<any>[] | Promise<any[]>;
@@ -64,6 +86,7 @@ declare module "@slash-graphql/lambda-types" {
6486
type GraphQLEvent = GraphQLEventCommonFields & {
6587
parents: Record<string, any>[] | null;
6688
args: Record<string, any>;
89+
info: InfoField;
6790
};
6891

6992
type WebHookGraphQLEvent = GraphQLEventCommonFields & {

src/script-to-express.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function bodyToEvent(b: any): GraphQLEventFields {
99
args: b.args || {},
1010
authHeader: b.authHeader,
1111
event: b.event || {},
12+
info: b.info || null,
1213
}
1314
}
1415

@@ -19,7 +20,7 @@ export function scriptToExpress(source: string) {
1920
app.post("/graphql-worker", async (req, res, next) => {
2021
try {
2122
const result = await runner(bodyToEvent(req.body));
22-
if(result === undefined) {
23+
if(result === undefined && req.body.resolver !== '$webhook') {
2324
res.status(400)
2425
}
2526
res.json(result)

0 commit comments

Comments
 (0)