github.com/maeglindeveloper/gqlgen@v0.13.1-0.20210413081235-57808b12a0a0/example/federation/integration-test.js (about) 1 const {InMemoryCache} = require("apollo-cache-inmemory"); 2 const {HttpLink} = require("apollo-link-http"); 3 const {ApolloClient} = require("apollo-client"); 4 const fetch = require("node-fetch"); 5 const gql = require('graphql-tag'); 6 7 var uri = process.env.SERVER_URL || 'http://localhost:4000/'; 8 9 const client = new ApolloClient({ 10 link: new HttpLink({uri, fetch}), 11 cache: new InMemoryCache(), 12 }); 13 14 describe('Json', () => { 15 it('can join across services', async () => { 16 let res = await client.query({ 17 query: gql`query { 18 me { 19 username 20 reviews { 21 body 22 product { 23 name 24 upc 25 } 26 } 27 } 28 }`, 29 }); 30 31 expect(res.data).toEqual({ 32 "me": { 33 "__typename": "User", 34 "username": "Me", 35 "reviews": [ 36 { 37 "__typename": "Review", 38 "body": "A highly effective form of birth control.", 39 "product": { 40 "__typename": "Product", 41 "name": "Trilby", 42 "upc": "top-1" 43 } 44 }, 45 { 46 "__typename": "Review", 47 "body": "Fedoras are one of the most fashionable hats around and can look great with a variety of outfits.", 48 "product": { 49 "__typename": "Product", 50 "name": "Trilby", 51 "upc": "top-1" 52 } 53 } 54 ] 55 } 56 }); 57 expect(res.errors).toBe(undefined); 58 }); 59 }); 60