Skip to content

Commit

Permalink
Compile expression ahead of time (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane32 authored Oct 11, 2022
1 parent 9cf539c commit aef07b8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/GraphQL.Relay/Types/NodeGraphType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ public FieldType Id<TReturnType>(string name, Expression<Func<T, TReturnType>> e
.FieldType.Metadata["RelayLocalIdField"] = true;
}

var fn = expression.Compile();

var field = Field(
name: "id",
description: $"The Global Id of the {Name ?? "node"}",
type: typeof(NonNullGraphType<IdGraphType>),
resolve: context => Node.ToGlobalId(
context.ParentType.Name,
expression.Compile()(context.Source)
fn(context.Source)
)
);

Expand Down

0 comments on commit aef07b8

Please sign in to comment.