Skip to content

Instantly share code, notes, and snippets.

View MBehtemam's full-sized avatar
🦄
Full Of Energey

Mohammad Bagher Ehtemam MBehtemam

🦄
Full Of Energey
View GitHub Profile
@MBehtemam
MBehtemam / cloudSettings
Last active December 5, 2020 18:59
myvs-code
{"lastUpload":"2020-12-05T18:59:27.148Z","extensionVersion":"v3.4.3"}
@MBehtemam
MBehtemam / GraphQLController.cs
Created December 1, 2018 08:46
GraphQL Controller
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
@MBehtemam
MBehtemam / GraphQLQuery.cs
Created December 1, 2018 08:41
GraphQL Query
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; }
@MBehtemam
MBehtemam / TodoSchema.cs
Created December 1, 2018 08:36
Todo Schema
using System;
using GraphQL;
using GraphQL.Types;
namespace TodoAPI.Models
{
public class TodoSchema : Schema
{
public TodoSchema(Func<Type, GraphType> resolveType)
: base(resolveType)
@MBehtemam
MBehtemam / FirstQuery.cs
Created December 1, 2018 08:02
First Query
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
);
@MBehtemam
MBehtemam / TodoQuery.cs
Created December 1, 2018 07:55
TodoQuery.cs
using System;
using GraphQL.Types;
using GraphQL;
using TodoAPI.Data;
namespace TodoAPI.Models
{
public class TodoQuery : ObjectGraphType
{
public TodoQuery(ITodoRepository todoRepository)
{
@MBehtemam
MBehtemam / TodoType.cs
Created December 1, 2018 07:00
Todo Type
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");
@MBehtemam
MBehtemam / TodoRepository.cs
Created December 1, 2018 05:13
todo repository
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using TodoAPI.Models;
namespace TodoAPI.Data
{
public class TodoRepository : ITodoRepository
{
@MBehtemam
MBehtemam / ITodoRepository.cs
Created December 1, 2018 04:03
ITodo Repository
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();
@MBehtemam
MBehtemam / Todo.cs
Created December 1, 2018 03:56
Todo Model
using System;
namespace TodoAPI.Models
{
public class Todo
{
public int Id { get; set; }
public string Title { get; set; }
public bool Completed { get; set; }
}