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
{"lastUpload":"2020-12-05T18:59:27.148Z","extensionVersion":"v3.4.3"} |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Mvc; | |
using GraphQL; | |
using GraphQL.Types; | |
using TodoAPI.Models; | |
using TodoAPI.Data; | |
namespace TodoAPI.Controllers |
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
using System; | |
namespace TodoAPI.Models | |
{ | |
public class GraphQLQuery | |
{ | |
public string OperationName { get; set; } | |
public string NamedQuery { get; set; } | |
public string Query { get; set; } | |
public string Variables { get; set; } |
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
using System; | |
using GraphQL; | |
using GraphQL.Types; | |
namespace TodoAPI.Models | |
{ | |
public class TodoSchema : Schema | |
{ | |
public TodoSchema(Func<Type, GraphType> resolveType) | |
: base(resolveType) |
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
Field<TodoType>("todo", arguments: new QueryArguments( | |
new QueryArgument<NonNullGraphType<IntGraphType>> { Name = "id", Description = "id of todo" } | |
), | |
resolve: context => todoRepository.GetTodoById(context.GetArgument<int>("id")).Result | |
); |
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
using System; | |
using GraphQL.Types; | |
using GraphQL; | |
using TodoAPI.Data; | |
namespace TodoAPI.Models | |
{ | |
public class TodoQuery : ObjectGraphType | |
{ | |
public TodoQuery(ITodoRepository todoRepository) | |
{ |
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
using System; | |
using GraphQL.Types; | |
using TodoAPI.Data; | |
namespace TodoAPI.Models | |
{ | |
class TodoType : ObjectGraphType<Todo> | |
{ | |
public TodoType(ITodoRepository todoRepository) | |
{ | |
Field(x => x.Id).Description("Id of Todo"); |
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
using System; | |
using System.Threading.Tasks; | |
using System.Collections.Generic; | |
using System.Linq; | |
using TodoAPI.Models; | |
namespace TodoAPI.Data | |
{ | |
public class TodoRepository : ITodoRepository | |
{ |
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
using System; | |
using TodoAPI.Models; | |
using System.Threading.Tasks; | |
using System.Collections.Generic; | |
namespace TodoAPI.Data | |
{ | |
public interface ITodoRepository | |
{ | |
Task<Todo> GetTodoById(int id); | |
Task<List<Todo>> GetTodos(); |
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
using System; | |
namespace TodoAPI.Models | |
{ | |
public class Todo | |
{ | |
public int Id { get; set; } | |
public string Title { get; set; } | |
public bool Completed { get; set; } | |
} |
NewerOlder