Comments (2)
Thanks your taking your time to explore and use graphql-go
, we appreciate it very much.
I've added comments to your original stack overflow question, I'll elaborate it more here
As, I am from Angular Background this Relay concept are still very confusing to me. How relay works in facilitating the communication between clients and server.
Yeah you are right that Relay has some concepts that would take a while for one to wrap their head around.
(I had planned to write a whole series for GraphQL+Relay, but unfortunately I had to put that on hold for the moment, I do want to go back in and just bang out a whole bunch of them out)
You can use GraphQL without Relay. Relay just works really well with GraphQL + React stack. it's just a library that helps with certain use-cases that otherwise you would have to implement yourself, namely:
- co-location of GraphQL data with your React code (similar to how you can co-locate your HTML markup with React code
- Imagine that each of your React components declare its own GraphQL query for exactly what it needs. Now imagine that you have a bigger component that is composed of these little components. Relay helps to merge and figure out one big GraphQL query that would allow you to get all the data to render your React component in one call
- Relay helps with tracking mutations done to your data objects that you retrieved from your GraphQL endpoints. Thats where it introduces these new concepts of Nodes, Edges, Connections, Global IDs (that are not part of GraphQL). Relay essentially assign store your data as a graph and gives you extra goodies like optimistic updates and data consistency.
Regarding paginations:
Paginations are not part of GraphQL specs but it is part of the Relay library as Connections.
But you can implement paginations without Relay by defining input arguments for your GraphQL objects.
For example:
friendType := graphql.NewObject(...) // define your `friend` type
query := graphql.NewObject(&graphql.ObjectConfig{
Name: "Query",
Fields: graphql.Fields{
"friends": &graphql.Field{
Type: graphql.NewList(friendType),
Args: graphql.FieldConfigArgument{
"first": &graphql.ArgumentConfig{
Type: graphql.Int,
},
},
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
// get and type assert argument
first, _ := p.Args["first"].(int)
// add logic here to retrieve and paginate your data based on the `first` argument
return getFriends(first)
},
},
},
});
Btw, the example GraphQL query you have seems a bit wonky. It should be
friends(first: 1) { // instead of friends.first(1)
cursor
node {
name
}
}
where friends
object accepts first
input argument of type GraphQLInt
.
I will try to find time to create an example for pagination for graphql-go, seems like it would be very useful for a lot of people.
(Or if anyone wants to contribute to the existing examples
folder, PRs are more than welcomed =))
Do share more ideas of what you think would be useful, for the benefit of the whole GraphQL community 👍
Cheers!
from graphql.
@sogko Thanks a lot for your fast response it helped me very much. I would also love to contribute GraphQL community
of golang
once I build graphQL endpoints for my needs.
from graphql.
Related Issues (20)
- Cannot parse GitHub public schema v4
- Create graphql schema from string HOT 3
- The code generator does not take into account naming conflicts HOT 1
- How to take metro in graphql out of the solve?
- Is this project still mantained? HOT 2
- New release?
- Potential goroutine leak in TestContextDeadline HOT 1
- Enums with trailing white space cause error.
- Playground
- make union input type ? it just have output union type
- With fiber HOT 1
- Printing GraphQL documents is slow HOT 1
- Bug with underscore and same name in keys from json response
- MongoDB _id field
- Printer returns invalid SDL if Block String comment contains double-quote
- When using custom scalar types, it's crucial to provide error feedback to users when issues arise with their submitted data. However, triggering exceptions within the ParseValue and ParseLiteral methods can lead to program crashes when using the graphql.Do method. This prevents the necessary error messages from being delivered to users.
- String type no longer recongised HOT 1
- Is it possible to go from `*graphql.Schema` to an ast node? HOT 1
- Error handling HOT 1
- Disabling Field Suggestions
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.