I need a graphql client lib to run on node.js for some testing and some data mashup - not in a production capacity. I\'m using apollo everywhere else (
Apollo Client should work just fine on Node. You only have to install cross-fetch because it assumes fetch exists.
Here is a complete TypeScript implementation of Apollo Client working on Node.js.
import ApolloClient, { gql } from "apollo-boost";
import { InsertJob } from "./graphql-types";
import 'cross-fetch/polyfill';
const client = new ApolloClient({
uri: "http://localhost:3000/graphql"
});
client.mutate({
mutation: gql`mutation insertJob($companyName: String!) {
addCompany(input: { displayName: $companyName } ) {
id
}
}`,
variables: {
companyName: "aaa"
}
})
.then(result => console.log(result));