-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from graphql-dotnet/helpers-and-logging
Helper functions and logging
- Loading branch information
Showing
12 changed files
with
171 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/GraphQL.Conventions/Types/Utilities/EnumerableExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace GraphQL.Conventions | ||
{ | ||
public static class EnumerableExtensions | ||
{ | ||
public static IEnumerable<V> Select<U, V>(this NonNull<IEnumerable<U>> list, Func<U, V> selector) => | ||
list.Value.Select(selector); | ||
|
||
public static IEnumerable<V> Select<U, V>(this NonNull<List<U>> list, Func<U, V> selector) => | ||
list.Value.Select(selector); | ||
|
||
public static IEnumerable<U> Where<U>(this NonNull<IEnumerable<U>> list, Func<U, bool> predicate) => | ||
list.Value.Where(predicate); | ||
|
||
public static IEnumerable<U> Where<U>(this NonNull<List<U>> list, Func<U, bool> predicate) => | ||
list.Value.Where(predicate); | ||
|
||
public static U FirstOrDefault<U>(this NonNull<IEnumerable<U>> list, Func<U, bool> predicate) => | ||
list.Value.FirstOrDefault(predicate); | ||
|
||
public static U FirstOrDefault<U>(this NonNull<List<U>> list, Func<U, bool> predicate) => | ||
list.Value.FirstOrDefault(predicate); | ||
|
||
public static U First<U>(this NonNull<IEnumerable<U>> list, Func<U, bool> predicate) => | ||
list.Value.First(predicate); | ||
|
||
public static U First<U>(this NonNull<List<U>> list, Func<U, bool> predicate) => | ||
list.Value.First(predicate); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace GraphQL.Conventions | ||
{ | ||
public static class Utilities | ||
{ | ||
public static NonNull<IEnumerable<T>> NonNull<T>(IEnumerable<T> items) => items.ToList(); | ||
|
||
public static NonNull<List<T>> NonNull<T>(List<T> items) => items; | ||
|
||
public static NonNull<string> NonNull(string str) => str; | ||
|
||
public static Id Id(string encodedIdentifier) => new Id(encodedIdentifier); | ||
|
||
public static Id Id<T>(string unencodedIdentifier, bool serializeUsingColon = true) => | ||
GraphQL.Conventions.Id.New<T>(unencodedIdentifier, serializeUsingColon); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
|
||
namespace GraphQL.Conventions | ||
{ | ||
public interface ILogger | ||
{ | ||
void Trace(string message); | ||
|
||
void Info(string message); | ||
|
||
void Warning(string message, Exception exception = null); | ||
|
||
void Error(string message, Exception exception = null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.