-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCharacterQueries.cs
52 lines (48 loc) · 1.65 KB
/
CharacterQueries.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System.Collections.Generic;
using HotChocolate;
using HotChocolate.Data;
using HotChocolate.Types;
using HotChocolate.Types.Relay;
using StarWars.Repositories;
namespace StarWars.Characters
{
[ExtendObjectType("Query")]
public class CharacterQueries
{
/// <summary>
/// Retrieve a hero by a particular Star Wars episode.
/// </summary>
/// <param name="episode">The episode to look up by.</param>
/// <param name="repository"></param>
/// <returns>The character.</returns>
public ICharacter GetHero(
Episode episode,
[Service]ICharacterRepository repository) =>
repository.GetHero(episode);
/// <summary>
/// Gets all character.
/// </summary>
/// <param name="repository"></param>
/// <returns>The character.</returns>
[UsePaging]
[UseFiltering]
[UseSorting]
public IEnumerable<ICharacter> GetCharacters(
[Service]ICharacterRepository repository) =>
repository.GetCharacters();
/// <summary>
/// Gets a character by it`s id.
/// </summary>
/// <param name="ids">The ids of the human to retrieve.</param>
/// <param name="repository"></param>
/// <returns>The character.</returns>
public IEnumerable<ICharacter> GetCharacter(
int[] ids,
[Service]ICharacterRepository repository) =>
repository.GetCharacters(ids);
public IEnumerable<ISearchResult> Search(
string text,
[Service]ICharacterRepository repository) =>
repository.Search(text);
}
}