Skip to content

Commit aef07b8

Browse files
authored
Compile expression ahead of time (#183)
1 parent 9cf539c commit aef07b8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/GraphQL.Relay/Types/NodeGraphType.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,15 @@ public FieldType Id<TReturnType>(string name, Expression<Func<T, TReturnType>> e
8888
.FieldType.Metadata["RelayLocalIdField"] = true;
8989
}
9090

91+
var fn = expression.Compile();
92+
9193
var field = Field(
9294
name: "id",
9395
description: $"The Global Id of the {Name ?? "node"}",
9496
type: typeof(NonNullGraphType<IdGraphType>),
9597
resolve: context => Node.ToGlobalId(
9698
context.ParentType.Name,
97-
expression.Compile()(context.Source)
99+
fn(context.Source)
98100
)
99101
);
100102

0 commit comments

Comments
 (0)