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

Does apollo-client work on node.js?

Apollo Client should work just fine on Node. You only have to install cross-fetch. Here is a complete TypeScript implementation of Apollo Client working on Node.js. import { ApolloClient, gql, HttpLink, InMemoryCache } from “@apollo/client”; import { InsertJob } from “./graphql-types”; import fetch from “cross-fetch”; const client = new ApolloClient({ link: new HttpLink({ uri: process.env.PRODUCTION_GRAPHQL_URL, … Read more

Apollo GraphQL React – how to query on click?

You can do it by passing a reference to Apollo Client using the withApollo higher-order-component, as documented here: https://www.apollographql.com/docs/react/api/react-apollo.html#withApollo Then, you can call client.query on the passed in object, like so: class MyComponent extends React.Component { runQuery() { this.props.client.query({ query: gql`…`, variables: { … }, }); } render() { … } } withApollo(MyComponent); Out of … Read more