GithubHelp home page GithubHelp logo

fiyazbinhasan / graphqlcore Goto Github PK

View Code? Open in Web Editor NEW
124.0 4.0 24.0 1.01 MB

Learn how to implement scalable APIs with GraphQL and ASP.NET Core. Branch wise code with relevant topic for smooth and easy walkthrough.

Home Page: http://fiyazhasan.me/tag/graphql-dotnet/

C# 94.90% CSS 0.35% JavaScript 4.75%
graphql graphql-dotnet series aspnetcore

graphqlcore's Introduction

GraphQL with ASP.NET Core - A 10 Part Blog Series

This repository contains a series of posts with branch wise code on builing scalable GraphQL end-points with ASP.NET Core. Each branch has its own readme where you can find rach relevent post. You can also read the series from my blog,

http://fiyazhasan.me/tag/graphql-dotnet/

Ask anything you want in the comment section of my blog.

Running the application

  • Download the zip or clone the project
  • Make sure you have necessary dotnet core sdks installed (I'm using ASP.NET Core 2.1)

https://www.microsoft.com/net/download/windows

  • Build and run the project

dotnet build dotnet run

Optional ( If you want a real database behind the scene )

  • Make sure you have Postgres installed in your system

https://postgresapp.com/

  • Change the connection string in appsettings.json to target your local posgres database.
  • From command line go to the root of the project and create a db migration script

dotnet ef migrations add Initial -o Data/Migrations

  • Apply migration in your database

dotnet ef database update

Branches

Part I - Hello World

Part II - Middleware

Part III - Dependency Injection

Part IV - GraphiQL - An in-browser IDE

Part V - Fields, Arguments, Variables

Part VI - Persist Data - Postgres with EF Core

Part VII - Mutation

Part VIII - Entity Relations - One to Many

Part IX - Entity Relations - Many to Many

Part X - Data Loader

Video Tutorials

Coming Soon...

Mentions

Joe McBride - Thanks for providing an awesome community driven project

graphql-dotnet

Jon Galloway - Thanks for featuring posts on ASP.NET Community Standup

graphqlcore's People

Contributors

fiyazbinhasan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

graphqlcore's Issues

Part X - Dataloader - Many to many

This works great but how to do many to many with the dataLoader?

Lets say i want to fetch the companies with there contacts (and a contact can have multiple companies).
I have a companyLinks as midde table (with companyId/contactId).

I have this which works when there is only 1 contact for a company:

public async Task<ILookup<Guid, Contact>> GetContactsFromCompanyBatchAsync(IEnumerable<Guid> companyIds)    
{
  var contacts = _entities.Include(c => c.CompanyLinks).Where(contact => contact.CompanyLinks.Any(cl => companyIds.Contains(cl.CompanyId)));
  return contacts.ToLookup(cont => {
       var res = cont.CompanyLinks.Any() ? cont.CompanyLinks.ElementAt(0).CompanyId : Guid.Empty;
       return res;
  });
}

But what if a contact has more then 1 company? How can i know the correct companyId ?

stackoverflow

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.