GraphQL dynamic query building

GraqhQL provides directives for this very purpose. Create a fragment to define common fields, use @include(if: Boolean) and @skip(if: Boolean) directives on that fragment to get dynamic fields. By dynamic fields we mean fields that are known at execution time. According to spec, it is best to avoid manual string interpolation to construct dynamic queries. … Read more

GraphQL mutation that accepts an array of dynamic size and common scalar types in one request

You can pass an array like this var MovieSchema = ` type Movie { name: String } input MovieInput { name: String } mutation { addMovies(movies: [MovieInput]): [Movie] } ` Then in your mutation, you can pass an array like mutation { addMovies(movies: [{name: ‘name1’}, {name: ‘name2′}]) { name } } Haven’t tested the code … Read more

What is the difference between useQuery and useLazyQuery in Apollo graphQL?

When useQuery is called by the component, it triggers the query subsequently. But when useLazyQuery is called, it does not trigger the query subsequently, and instead return a function that can be used to trigger the query manually. It is explained on this page: https://www.apollographql.com/docs/react/data/queries/#manual-execution-with-uselazyquery When React mounts and renders a component that calls the … Read more

How to correctly declare a GraphQL query without parameters.

The queries you specify in your schema behave just like any other field on a particular type (the main difference is that their type is linked to a particular operation). If you don’t want to declare any arguments for a particular field, you just omit the parentheses entirely. The same goes for queries and mutations: … Read more

What is the difference between OData, JsonAPI, GraphQL?

OData is a similar specification to JSON API. Both of them describe a standard protocol for creation and consumption of RESTful APIs. GraphQL is a totally different approach to API design and specifies a different way of querying API resources. OData: Designed and developed at Microsoft since 2007, standardized by the OASIS consortium. The latest … Read more

Github graphQL OrderBy

You’ve got an error Argument ‘orderBy’ on Field ‘repositories’ has an invalid value. Expected type ‘RepositoryOrder’. You forget to specify direction which is marked as mandatory. This will work: { repositoryOwner(login: “Naramsim”) { login repositories(first: 3, isFork: true, orderBy: {field: CREATED_AT, direction: ASC}) { edges { node { description } } } } }