IEnumerable <GraphQLFieldDefinition> IGraphQLMapper.CreateFields(GraphQLMapperContext context) { yield return (GraphQLFieldDefinition .FromContext(context) .WithType(_ => GraphTypesByType[context.Type].MakeNullableIf(context.IsNullable))); }
IEnumerable <GraphQLFieldDefinition> IGraphQLMapper.CreateFields(GraphQLMapperContext context) { var descriptor = Entity.GetDescriptorFromType(context.Type); var entityType = _entityTypesByDescriptor[descriptor]; yield return (GraphQLFieldDefinition .FromContext(context) .WithType(_ => entityType.MakeNullableIf(context.IsNullable))); yield return (GraphQLFieldDefinition .FromContext(context) .WithName(name => $"{name}Id") .WithDescription(description => $"{description} (ID)") .WithType(_ => new IdGraphType().MakeNullableIf(context.IsNullable)) .WithResolver(resolver => async resolveContext => { var entity = (IEntity)await resolver(resolveContext); return entity.Id; })); }