chkimes / graphql-net

Convert GraphQL to IQueryable
MIT License
891 stars 86 forks source link

Alias support for AddAllFields #95

Closed JimmyAtSchotte closed 4 years ago

JimmyAtSchotte commented 6 years ago

Faced a problem where our database uses prefixes and we dont want them in our api. I could have just use AddField with an alias, but since we allready have AutoMapper set up I wanted to use that configuration to avoid writing the configuration twice.

With this modification Im able to do like this:

var mapping = AutoMapper.Mapper.Configuration.FindTypeMapFor<TEntity, TModel>();

schema.AddAllFields(mapping.GetPropertyMaps().ToDictionary(key => key.SourceMember.Name, val => val.DestinationProperty.Name));