mmacneil / aspnetcoregraphql Goto Github PK
View Code? Open in Web Editor NEWSample project demonstrating a GraphQL service built with ASP.NET Core 2.2, Entity Framework Core and graphql-dotnet.
License: MIT License
Sample project demonstrating a GraphQL service built with ASP.NET Core 2.2, Entity Framework Core and graphql-dotnet.
License: MIT License
adding a player with mutation:
mutation ($player: PlayerInput!){
createPlayer(player: $player){
id
name
birthDate
}
}
and variables:
{
"player":{
"name":"test"
}
}
creates the player, with no validation for any field.
then reading the player generates the following error:
{
"data": {
"player": {
"name": "test",
"birthDate": "0001-01-01",
"birthPlace": null,
"weightLbs": 0
}
},
"errors": [
{
"message": "GraphQL.ExecutionError: Cannot return null for non-null type. Field: birthPlace, Type: String!.\r\n at GraphQL.Execution.ExecutionStrategy.ValidateNodeResult(ExecutionContext context, ExecutionNode node)\r\n at GraphQL.Execution.ExecutionStrategy.ExecuteNodeAsync(ExecutionContext context, ExecutionNode node)",
"locations": [
{
"line": 5,
"column": 5
}
],
"path": [
"player",
"birthPlace"
]
}
]
}
can you add validation please so that bad data can not be saved?
Can you also add the postman collection to this solution? This is very easy to use when testing the api.
If you can add schema generator to the project it would be great.
This minimizes lot of code. But I am struggling with its implemantation.
All the time it gives error like method not found. You can extend your post which can be helpful to many who wants to implement graphql with their existing classes.
Hi! I cloned the repo and built it using .Net Core SDK 2.2.106. I use Visual Studio 2017, 15.9.11 on Window Server 2012. The solution builds successfully and I see db populated with records. However when I debug I was directed to localhost:56543 with message "This localhost page can’t be found No webpage was found for the web address: http://localhost:56543/". The port 56543 was found on NHLStats.Api project / Properties / launchSettings.json. I tried to send request using Postman but no luck. I am new to GraphQL and suspect this is an IIS issue. What goes wrong here?
Current build does not allow you to create an entity and then with another mutation delete that entity.
Steps to reproduce:
mutation ($day: DayInput!) {
createDay(day:$day){
id
agendaDay
}
}
mutation ($day: DayInput!) {
createDay(day:$day){
id
agendaDay
}
}
mutation ($dayId: Int!) {
deleteDay(dayId:$dayId){
id
agendaDay
}
}
{
"dayId" : "7004"
}
I get the following error
{
"data": {
"deleteDay": null
},
"errors": [
{
"message": "There was an error deleting 7004: The instance of entity type 'Day' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the conflicting key values.",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"deleteDay"
]
}
]
}
I believe this line is the reason
var sp = services.BuildServiceProvider();
services.AddSingleton<ISchema>(new MITSSchema(new FuncDependencyResolver(type =>sp.GetService(type))));
I replaced it with below and it works as expected.
services.AddScoped<IDependencyResolver>(s => new FuncDependencyResolver(s.GetRequiredService));
I tried the below using VSCode and got the error related to connectionstring.
I have updated the connectionstring to "NHLStatsDb": "Data Source=.;Initial Catalog=NHLStats;Trusted_Connection=True;MultipleActiveResultSets=true"
On running the command by navigating to the dotnet run command from the root of the \NHLStats.Api folder
I am getting the following error:
Application startup exception: System.ArgumentNullException: Value cannot be null.
Parameter name: connectionString
at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
at Microsoft.EntityFrameworkCore.SqlServerDbContextOptionsExtensions.UseSqlServer(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 sqlServerOptionsAction)
I opened the project using VS2017 and found all this works fine.
Any help on this is much appreciated
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.