hotchocolate | Hot Chocolate GraphQL server for .NET , the Strawberry | GraphQL library
kandi X-RAY | hotchocolate Summary
kandi X-RAY | hotchocolate Summary
Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of hotchocolate
hotchocolate Key Features
hotchocolate Examples and Code Snippets
Community Discussions
Trending Discussions on hotchocolate
QUESTION
I have currently created a .net backend with HotChocolate to create GraphQL queries. The reason for that is that I feel more in control when using API Gateway.
However, I have noticed that AppSync is maybe the preferred way of connecting DynamoDB with GraphQL.
But, I cannot find any good answers on how to trigger other lambdas when e.g. updating a user. Say I want to update a user, when the user is updated, I want to trigger a Lambda that notifies all the users on a certain list that the user is updated. My problem is more complex than that, but you get the point.
Another thing is authorization. It seems easier to authorize through AppSync rather than in either API Gateway or directly in the backend.
...ANSWER
Answered 2022-Mar-08 at 18:49I cannot find any good answers on how to trigger other lambdas when e.g. updating a user.
Defining your Appsync resolvers as Direct Lambda Resolvers gives you the opportunity to perform work as part of the GraphQL request-response cycle. Appsync invokes your lambda with the updateUser
mutation request context and parameters. In addition to returning the requested type back to Appsync, your lambda can perform arbitrary work or trigger other work.
I have noticed that AppSync is maybe the preferred way of connecting DynamoDB with GraphQL
AppSync is AWS's managed GraphQL service.
It seems easier to authorize through AppSync rather than in either API Gateway or directly in the backend
AppSync has multiple integrated auth options, supporting a range of simple and fine-grained access control patterns.
QUESTION
So I'm trying to figure out how to tell EfCore when to apply an include to an IQueryable object based on whether the GraphQl request from the client actually includes the related object.
Example:
2 Classes: Person, Payment
Theses are kept in 2 different tables and related Person -> Payment in a one to many relationship
I have 1 GraphQl Query set up to retrieve all people in the Database:
...
ANSWER
Answered 2021-Dec-23 at 15:15Tobias Tengler was correct this should be done through Projections
QUESTION
I cant seem to get Projections with HotChocolate working for GraphQl. According to the documentation Projections should prevent over-requesting of data from the DB, and help connect data in related tables. As a simple example I set up the following:
...ANSWER
Answered 2021-Dec-23 at 13:59Turns out after much trial and error that I had the attribute tags in the wrong order should be:
QUESTION
I am new to GraphQL. Whenever I am running my project it shows
server is not reachable
I have crosschecked project files and I guess the issue is with the Startup.cs
file. I am trying to use app.UseGraphQL
in Configure function but the IDE could not suggest me a correct library for it.
This is my code:
...ANSWER
Answered 2021-Dec-21 at 05:57Can you modify your code like this.
QUESTION
We recently introduced GraphQL to our project, I've never used it before, however I like it a lot. We decided to go with the HotChocolate library for .NET Core and Apollo for client side.
One thing I am not quite sure is about mutations, specifically peforming updates and partial updates with mutations. I read somewhere that the practice is and that I should stick with creating specific mutation for each update, for instance updateUsername(), updateAddress(), updateCity() all of them should have specific mutation.
Issue with that is that my codebase will grow enormously if I decide to go in that direction, as we are very much data driven, with a lot of tables and columns per table.
Another question is, how to handle nullable properties, I can create a mutation which accepts some input object, but I'll end up with my entity being overwritten and all nullable properties not provided on the calling end will be set to null. Is there a way to handle this update partially or I should go with specific update mutation for each property I want updated?
...ANSWER
Answered 2021-Dec-04 at 16:17I think you understood the best practice around specific mutations wrong. It's less "have one mutation to update one field" and more "have specific mutations that encapsulate actions in your domain". A concrete example would be creating an "addItemToBasket" mutation, instead of having 3 mutations that update the individual tables related to your shopping basket, etc.
GraphQL is very much centered around front-end development, so your mutations should, in general, closely resemble actions a user can perform in your front-end. E.g. your front-end has an "Add to basket" button and your backend has an "addItemToBasket" mutation that resembles the action of placing an item in the user's basket.
If you design your mutations with this in mind, most of the time you shouldn't be having an issue with partial updates, since the mutation knows exactly what's to do and you are not just letting the user of your schema update fields at will.
If for whatever reason you need to have these partial updates, you likely won't get around implementing the patching yourself, unless your data provider supports it. Meaning you will have to have an input object type with nullable properties and your mutation that decides which fields have been changed and changing them using your data provider.
That being said, there's also a proposal for patching types in the Hot Chocolate repository that should simplify the patching part: https://github.com/ChilliCream/hotchocolate/issues/1326
QUESTION
I am trying to implement schema-first in Hot Chocolate and running into SchemaException
I have the below GraphQL Schema
...ANSWER
Answered 2021-Nov-26 at 13:25The GraphQL spec states that the interface fields have to be repeated on the type.
QUESTION
I'm trying to wrap my head around GraphQL in general and a HotChocolate demo I just watched. Here's what I see as benefits:
- Client can request any combination of fields thus offering maximum flexibility
- Queries are directly translated into SQL resulting in high performance and little overhead
My question or concern, if you want so, is: doesn't this couple my API to the database at a level that's almost certain to break at some point? If I need to adjust my DB schema, things will break. Is this concern valid?
...ANSWER
Answered 2021-Nov-26 at 11:57Hot Chocolate or GraphQL in general are only meant to be a tiny wrapper on top of your existing APIs.
What's shown as a resolver in the demo
QUESTION
I'm implementing a very simple query using the HotChocolate
GraphQL library in a .Net 5 project. I've been following the tutorial series from the HotChocolate GitHub repository but in my project I don't want GraphQL accessing the context directly and would instead prefer for it to access a repository that manages database access via the context.
I've built a few REST endpoints in this project alongside GraphQL and this repository pattern works properly there. However when I call these repository methods from a GraphQL, the context is disposed before the repository method uses it.
I am guessing that the way HotChocolate uses the context causes it to get disposed earlier than I am expecting, but I am having trouble figuring out when/where it gets disposed and how I can prevent it from being disposed so my repository methods will work.
ContentRepository.cs
...ANSWER
Answered 2021-Jul-29 at 15:40You can only use constructor injection with HotChocolate v11:
QUESTION
I am building a GraphQL endpoint with a user authentication service. For the user authentication, I'm using Entity Framework Core.
In the mutation resolver, when I used the constructor DI [Ref], I am getting below error when accessing the resolver for 2nd time. "Cannot access a disposed object.\r\nObject name: 'UserManager`1'."
As per the Hot Chocolate instruction, constructor DIs are singleton types, and not quite sure why I am getting this error.
However, If I use [Service] key word to inject in the resolver method. I am not getting any errors [Ref].
...ANSWER
Answered 2021-Oct-31 at 19:07So, If you do not declare anything Hot Chocolate will add the resolver classes as singleton. In your case with UserManager
I think it is a scoped service. So every resolver class that uses constructor injection in your case needs to be registered in the DI as well as a scoped service.
Alternatively you can use resolver level DI.
QUESTION
I'm using HotChocolate 12.0.1. I have following type definition:
...ANSWER
Answered 2021-Oct-06 at 02:13Really silly solution which took me 4 hours to find.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install hotchocolate
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page