Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public class GraphQlControllerTests
public async Task Single()
{
var query = @"
query ($id: Id!)
query ($id: ID!)
{
company(id:$id)
{
Expand All @@ -506,7 +506,7 @@ query ($id: Id!)
public async Task Single_not_found()
{
var query = @"
query ($id: Id!)
query ($id: ID!)
{
company(id:$id)
{
Expand All @@ -527,7 +527,7 @@ query ($id: Id!)
public async Task Variable()
{
var query = @"
query ($id: Id!)
query ($id: ID!)
{
companies(ids:[$id])
{
Expand Down
2 changes: 1 addition & 1 deletion docs/defining-graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class Query :
}
}
```
<sup><a href='/src/Snippets/RootQuery.cs#L5-L22' title='Snippet source file'>snippet source</a> | <a href='#snippet-rootquery' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Snippets/RootQuery.cs#L3-L20' title='Snippet source file'>snippet source</a> | <a href='#snippet-rootquery' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

`AddQueryField` will result in all matching being found and returned.
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<NoWarn>CS1591;NU5104;CS1573</NoWarn>
<Version>20.2.1</Version>
<Version>21.0.0</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
<PackageTags>EntityFrameworkCore, EntityFramework, GraphQL</PackageTags>
<ImplicitUsings>true</ImplicitUsings>
Expand Down
1 change: 0 additions & 1 deletion src/GraphQL.EntityFramework/EfGraphQLConventions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ static void RegisterScalarsAndArgs(IServiceCollection services)
services.AddSingleton<WhereExpressionGraph>();
services.AddSingleton<OrderByGraph>();
services.AddSingleton<ComparisonGraph>();
services.AddSingleton<IdGraph>();
services.AddSingleton<ConnectorGraph>();
}

Expand Down
11 changes: 0 additions & 11 deletions src/GraphQL.EntityFramework/GraphApi/EfInterfaceGraphType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,4 @@ public TDbContext ResolveDbContext(IResolveFieldContext<TSource> context) =>

public TDbContext ResolveDbContext(IResolveFieldContext context) =>
GraphQlService.ResolveDbContext(context);

public override FieldBuilder<TSource, TProperty> Field<TProperty>(
string name,
Expression<Func<TSource, TProperty>> expression,
bool nullable = false,
Type? type = null)
{
OverrideIdAttribute.Convert<TProperty>(ref type);

return base.Field(name, expression, nullable, type);
}
}
11 changes: 0 additions & 11 deletions src/GraphQL.EntityFramework/GraphApi/EfObjectGraphType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,4 @@ public FieldBuilder<TSource, TReturn> AddSingleField<TReturn>(
bool nullable = false)
where TReturn : class =>
GraphQlService.AddSingleField(this, name, resolve, mutate, graphType, nullable);

public override FieldBuilder<TSource, TProperty> Field<TProperty>(
string name,
Expression<Func<TSource, TProperty>> expression,
bool nullable = false,
Type? type = null)
{
OverrideIdAttribute.Convert<TProperty>(ref type);

return base.Field(name, expression, nullable, type);
}
}
4 changes: 0 additions & 4 deletions src/GraphQL.EntityFramework/Mapping/Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,6 @@ static Type GraphTypeFromType(string name, Type propertyType, bool isNullable)
{
try
{
if (OverrideIdAttribute.TryGetIdType(propertyType, out var graphType))
{
return graphType;
}
if (propertyType.TryGetCollectionType(out var collectionGenericType))
{
if (isNullable)
Expand Down
43 changes: 0 additions & 43 deletions src/GraphQL.EntityFramework/OverrideIdAttribute.cs

This file was deleted.

33 changes: 24 additions & 9 deletions src/GraphQL.EntityFramework/Where/ArgumentReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,39 @@ string ArgumentToExpression(object argument)
};
}

var idsArgument = context.GetArgument(typeof(object), "ids");
var idArgument = context.GetArgument(typeof(object), "id");
if (idsArgument is null && idArgument is null)
if (context.Arguments == null)
{
result = null;
return false;
}

var containsIds = context.Arguments.TryGetValue("ids", out var ids);
var containsId = context.Arguments.TryGetValue("id", out var id);

if (!containsIds && !containsId)
{
result = null;
return false;
}

if (ids.Source == ArgumentSource.FieldDefault && id.Source == ArgumentSource.FieldDefault)
{
result = null;
return false;
}

var expressions = new List<string>();

if (idArgument is not null)
if (id.Source != ArgumentSource.FieldDefault)
{
expressions.Add( ArgumentToExpression(idArgument));
expressions.Add(ArgumentToExpression(id.Value!));
}

if (idsArgument is not null)
if (ids.Source != ArgumentSource.FieldDefault)
{
if (idsArgument is not IEnumerable<object> objCollection)
if (ids.Value is not IEnumerable<object> objCollection)
{
throw new($"TryReadIds got an 'ids' argument of type '{idsArgument.GetType().FullName}' which is not supported.");
throw new($"TryReadIds got an 'ids' argument of type '{ids.Value!.GetType().FullName}' which is not supported.");
}

expressions.AddRange(objCollection.Select(ArgumentToExpression));
Expand All @@ -62,6 +75,7 @@ public static bool TryReadSkip(IResolveFieldContext context, out int skip)
throw new("Skip cannot be less than 0.");
}
}

return result;
}

Expand All @@ -75,6 +89,7 @@ public static bool TryReadTake(IResolveFieldContext context, out int take)
throw new("Take cannot be less than 0.");
}
}

return result;
}

Expand All @@ -98,7 +113,7 @@ static bool TryReadInt(string name, IResolveFieldContext context, out int value)
return false;
}

value = (int)argument;
value = (int) argument;
return true;
}
}
4 changes: 2 additions & 2 deletions src/GraphQL.EntityFramework/Where/ArgumentsAppender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ static QueryArgument<ListGraphType<NonNullGraphType<OrderByGraph>>> OrderByArgum
Name = "orderBy"
};

static QueryArgument<ListGraphType<NonNullGraphType<IdGraph>>> IdsArgument() =>
static QueryArgument<ListGraphType<NonNullGraphType<IdGraphType>>> IdsArgument() =>
new()
{
Name = "ids"
};

static QueryArgument<IdGraph> IdArgument() =>
static QueryArgument<IdGraphType> IdArgument() =>
new()
{
Name = "id"
Expand Down
28 changes: 0 additions & 28 deletions src/GraphQL.EntityFramework/Where/Graphs/IdGraph.cs

This file was deleted.

6 changes: 3 additions & 3 deletions src/SampleWeb.Tests/GraphQlControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public async Task Post()
public async Task Single()
{
var query = @"
query ($id: Id!)
query ($id: ID!)
{
company(id:$id)
{
Expand All @@ -79,7 +79,7 @@ public async Task Single()
public async Task Single_not_found()
{
var query = @"
query ($id: Id!)
query ($id: ID!)
{
company(id:$id)
{
Expand All @@ -100,7 +100,7 @@ public async Task Single_not_found()
public async Task Variable()
{
var query = @"
query ($id: Id!)
query ($id: ID!)
{
companies(ids:[$id])
{
Expand Down
20 changes: 9 additions & 11 deletions src/SampleWeb.Tests/SchemaPrint.Print.verified.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type Company {
employees(id: Id, ids: [Id!], where: [WhereExpression!], orderBy: [OrderBy!], skip: Int, take: Int): [Employee!]!
employeesConnection(after: String, first: Int, before: String, last: Int, where: [WhereExpression!], orderBy: [OrderBy!], ids: [Id!]): EmployeeConnection!
employees(id: ID, ids: [ID!], where: [WhereExpression!], orderBy: [OrderBy!], skip: Int, take: Int): [Employee!]!
employeesConnection(after: String, first: Int, before: String, last: Int, where: [WhereExpression!], orderBy: [OrderBy!], ids: [ID!]): EmployeeConnection!
content: String
id: Int!
}
Expand Down Expand Up @@ -61,8 +61,6 @@ type EmployeeSummary {
companyId: Int!
}

scalar Id

input OrderBy {
path: String!
descending: Boolean
Expand All @@ -76,13 +74,13 @@ type PageInfo {
}

type Query {
companies(id: Id, ids: [Id!], where: [WhereExpression!], orderBy: [OrderBy!], skip: Int, take: Int): [Company!]!
company(id: Id, ids: [Id!], where: [WhereExpression!]): Company!
companyOrNull(id: Id, ids: [Id!], where: [WhereExpression!]): Company
companiesConnection(after: String, first: Int, before: String, last: Int, where: [WhereExpression!], orderBy: [OrderBy!], ids: [Id!]): CompanyConnection!
employees(id: Id, ids: [Id!], where: [WhereExpression!], orderBy: [OrderBy!], skip: Int, take: Int): [Employee!]!
employeesByArgument(id: Id, ids: [Id!], where: [WhereExpression!], orderBy: [OrderBy!], skip: Int, take: Int, content: String): [Employee!]!
employeesConnection(after: String, first: Int, before: String, last: Int, where: [WhereExpression!], orderBy: [OrderBy!], ids: [Id!]): EmployeeConnection!
companies(id: ID, ids: [ID!], where: [WhereExpression!], orderBy: [OrderBy!], skip: Int, take: Int): [Company!]!
company(id: ID, ids: [ID!], where: [WhereExpression!]): Company!
companyOrNull(id: ID, ids: [ID!], where: [WhereExpression!]): Company
companiesConnection(after: String, first: Int, before: String, last: Int, where: [WhereExpression!], orderBy: [OrderBy!], ids: [ID!]): CompanyConnection!
employees(id: ID, ids: [ID!], where: [WhereExpression!], orderBy: [OrderBy!], skip: Int, take: Int): [Employee!]!
employeesByArgument(id: ID, ids: [ID!], where: [WhereExpression!], orderBy: [OrderBy!], skip: Int, take: Int, content: String): [Employee!]!
employeesConnection(after: String, first: Int, before: String, last: Int, where: [WhereExpression!], orderBy: [OrderBy!], ids: [ID!]): EmployeeConnection!
employeeSummary(where: [WhereExpression]): [EmployeeSummary]
}

Expand Down
4 changes: 1 addition & 3 deletions src/SampleWeb/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[assembly:OverrideId]

public class Program
public class Program
{
public static Task Main()
{
Expand Down
4 changes: 1 addition & 3 deletions src/Snippets/RootQuery.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[assembly:OverrideId]

class RootQuery
class RootQuery
{
#region rootQuery

Expand Down
Loading