Skip to content

Commit 35e434f

Browse files
authored
Add context to GetById (#88)
1 parent 5c2a3d6 commit 35e434f

File tree

11 files changed

+16
-16
lines changed

11 files changed

+16
-16
lines changed

src/GraphQL.Relay.StarWars/Types/Film.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public FilmGraphType(Swapi api)
6363
);
6464
}
6565

66-
public override Task<Films> GetById(string id) =>
66+
public override Task<Films> GetById(IResolveFieldContext<object> context, string id) =>
6767
_api.GetEntity<Films>(id);
6868
}
6969
}

src/GraphQL.Relay.StarWars/Types/People.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public PeopleGraphType(Swapi api)
6363
);
6464
}
6565

66-
public override Task<People> GetById(string id) =>
66+
public override Task<People> GetById(IResolveFieldContext<object> context, string id) =>
6767
_api.GetEntity<People>(id);
6868

6969
}

src/GraphQL.Relay.StarWars/Types/Planet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public PlanetGraphType(Swapi api)
4242
);
4343
}
4444

45-
public override Task<Planets> GetById(string id) =>
45+
public override Task<Planets> GetById(IResolveFieldContext<object> context, string id) =>
4646
_api.GetEntity<Planets>(id);
4747

4848
}

src/GraphQL.Relay.StarWars/Types/Species.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public SpeciesGraphType(Swapi api)
4848
);
4949
}
5050

51-
public override Task<Species> GetById(string id) =>
51+
public override Task<Species> GetById(IResolveFieldContext<object> context, string id) =>
5252
_api.GetEntity<Species>(id);
5353

5454
}

src/GraphQL.Relay.StarWars/Types/Starship.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public StarshipGraphType(Swapi api)
4646
);
4747
}
4848

49-
public override Task<Starships> GetById(string id) =>
49+
public override Task<Starships> GetById(IResolveFieldContext<object> context, string id) =>
5050
_api.GetEntity<Starships>(id);
5151

5252
}

src/GraphQL.Relay.StarWars/Types/Vehicle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public VehicleGraphType(Swapi api)
4545
);
4646
}
4747

48-
public override Task<Vehicles> GetById(string id) =>
48+
public override Task<Vehicles> GetById(IResolveFieldContext<object> context, string id) =>
4949
_api.GetEntity<Vehicles>(id);
5050

5151
}

src/GraphQL.Relay.Test/NodeTypeTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ public DroidType()
2727

2828
public class DroidType : DroidType<Droid>
2929
{
30-
public override Droid GetById(string id)
30+
public override Droid GetById(IResolveFieldContext<object> context, string id)
3131
{
3232
return new Droid { Id = id, Name = "text" };
3333
}
3434
}
3535

3636
public class DroidTypeAsync : DroidType<Task<Droid>>
3737
{
38-
public override async Task<Droid> GetById(string id)
38+
public override async Task<Droid> GetById(IResolveFieldContext<object> context, string id)
3939
{
4040
await Task.Delay(0);
4141
return new Droid { Id = id, Name = "text" };
@@ -57,7 +57,7 @@ public async void it_should_allow_async()
5757
{
5858
var type = new DroidTypeAsync();
5959

60-
var droid = await type.GetById("3");
60+
var droid = await type.GetById(null, "3");
6161
droid.Id.ShouldBe("3");
6262
}
6363
}

src/GraphQL.Relay.Test/Types/QueryGraphTypeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public SimpleNodeGraphType() : base()
3030
Id(x => x.Id);
3131
}
3232

33-
public override SimpleData GetById(string id) => SimpleData
33+
public override SimpleData GetById(IResolveFieldContext<object> context, string id) => SimpleData
3434
.GetData()
3535
.FirstOrDefault(x => x.Id.Equals(id));
3636

src/GraphQL.Relay.Todo/Schema/Query.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public TodoGraphType() {
2626
Field("complete", t => t.Completed);
2727
}
2828

29-
public override Todo GetById(string id) =>
29+
public override Todo GetById(IResolveFieldContext<object> context, string id) =>
3030
Database.GetTodoById(id);
3131
}
3232

@@ -61,7 +61,7 @@ public UserGraphType() {
6161
);
6262
}
6363

64-
public override User GetById(string id) =>
64+
public override User GetById(IResolveFieldContext<object> context, string id) =>
6565
Database.GetUserById(id);
6666
}
6767

src/GraphQL.Relay/Types/NodeGraphType.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class GlobalId
1515

1616
public interface IRelayNode<out T>
1717
{
18-
T GetById(string id);
18+
T GetById(IResolveFieldContext<object> context, string id);
1919
}
2020

2121
public static class Node
@@ -54,7 +54,7 @@ protected NodeGraphType()
5454
Interface<NodeInterface>();
5555
}
5656

57-
public abstract TOut GetById(string id);
57+
public abstract TOut GetById(IResolveFieldContext<object> context, string id);
5858

5959
public FieldType Id<TReturnType>(Expression<Func<T, TReturnType>> expression)
6060
{
@@ -131,7 +131,7 @@ public DefaultNodeGraphType(Func<string, TOut> getById)
131131
_getById = getById;
132132
}
133133

134-
public override TOut GetById(string id)
134+
public override TOut GetById(IResolveFieldContext<object> context, string id)
135135
{
136136
return _getById(id);
137137
}

0 commit comments

Comments
 (0)