Comments (3)
Hi, sure I can create an example during the upcoming weekend. I'll post a link here afterwards.
from graphql-dotnetcore.
+1 for this. Looking forward to the sample.
from graphql-dotnetcore.
Created a repo at https://github.com/mkmarek/graphql-dotnetcore-ef-example for now it contains just one query and one mutation but it should still explain one of the possibilities how to use it. I'll add more stuff and some furter explanation during the weekend hopefully. It went to be a little bit more difficult than I initially expected. But it's quite simmilar to a way how we use this library for real projects.
But basically it uses the CQRS pattern which I think works with GraphQL really well. For DB I used MSSQL but you can surely change that to whatever suits you. For the data access layer I picked unit of work pattern using https://github.com/arch/UnitOfWork library.
It also uses the ASP.NET core DI container quite heavily. You can notice that the graphql schema class doesn't really have anything. The flow is inverse. The types themselves are registering into the schema. The reason for that is here Another workaround would be of course possible if It managed those schema types outside the DI container.
I'm running quite old version of .NET core on my current laptop so you might have to upgrade the project.
To run it you need to:
- change the connection string at appsettings.json
- run the
dotnet ef database update
to populate your database - run it with
dotnet run
or through visual studio
Then if you go to http://localhost:yourport/public/index.html you should see the GraphiQL interface and there you can play around.
Enjoy!
Marek
from graphql-dotnetcore.
Related Issues (20)
- Implement graphql subscriptions HOT 1
- Validation ast visitor should support introspection types HOT 1
- Implement GraphQL union types HOT 1
- Parser Collaboration HOT 3
- Any plans for relay integration? HOT 2
- Support for nullable enums
- Fix null variables
- Migrate build process to MSBuild.net Core
- Add GraphQLID scalar type HOT 1
- Unique directives per location validation rule HOT 1
- Resolve type validation on subscriptions HOT 1
- Single Field Subscriptions validation rule HOT 1
- Add location information to graphql errors HOT 1
- Add path information to graphql errors HOT 1
- Better subscription support and demo HOT 1
- Initial support for @defer, @stream, and @live
- Create possibility to set description to to field in GraphQLObject HOT 1
- Create possibility to deprecate field HOT 1
- Create possibility to specify default value for field arguments HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-dotnetcore.