11import { inspect } from 'util' ;
22import { GraphQLSchema , parse , print } from 'graphql' ;
3+ import { createYoga } from 'graphql-yoga' ;
34import _ from 'lodash' ;
45import { IntrospectAndCompose , LocalGraphQLDataSource } from '@apollo/gateway' ;
56import { buildSubgraphSchema } from '@apollo/subgraph' ;
6- import { createDefaultExecutor } from '@graphql-tools/delegate' ;
77import { normalizedExecutor } from '@graphql-tools/executor' ;
8+ import { buildHTTPExecutor } from '@graphql-tools/executor-http' ;
89import { asArray , ExecutionResult , mergeDeep } from '@graphql-tools/utils' ;
10+ import { useDeferStream } from '@graphql-yoga/plugin-defer-stream' ;
911import { assertAsyncIterable } from '../../loaders/url/tests/test-utils' ;
1012import { getStitchedSchemaFromSupergraphSdl } from '../src/supergraph' ;
1113
@@ -98,6 +100,10 @@ describe('Defer/Stream', () => {
98100 } ,
99101 } ,
100102 } ) ;
103+ const usersServer = createYoga ( {
104+ schema : usersSubgraph ,
105+ plugins : [ useDeferStream ( ) ] ,
106+ } ) ;
101107 const postsSubgraph = buildSubgraphSchema ( {
102108 typeDefs : parse ( /* GraphQL */ `
103109 type Query {
@@ -141,6 +147,10 @@ describe('Defer/Stream', () => {
141147 } ,
142148 } ,
143149 } ) ;
150+ const postsServer = createYoga ( {
151+ schema : postsSubgraph ,
152+ plugins : [ useDeferStream ( ) ] ,
153+ } ) ;
144154 let schema : GraphQLSchema ;
145155 let finalResult : ExecutionResult ;
146156 beforeAll ( async ( ) => {
@@ -163,7 +173,10 @@ describe('Defer/Stream', () => {
163173 onSubschemaConfig ( subschemaConfig ) {
164174 const subgraphName = subschemaConfig . name . toLowerCase ( ) ;
165175 if ( subgraphName === 'users' ) {
166- const origExecutor = createDefaultExecutor ( usersSubgraph ) ;
176+ const origExecutor = buildHTTPExecutor ( {
177+ endpoint : 'http://localhost:4001/graphql' ,
178+ fetch : usersServer . fetch ,
179+ } ) ;
167180 subschemaConfig . executor = async function usersExecutor ( execReq ) {
168181 const result = await origExecutor ( execReq ) ;
169182 if ( process . env [ 'DEBUG' ] ) {
@@ -176,7 +189,10 @@ describe('Defer/Stream', () => {
176189 return result ;
177190 } ;
178191 } else if ( subgraphName === 'posts' ) {
179- const origExecutor = createDefaultExecutor ( postsSubgraph ) ;
192+ const origExecutor = buildHTTPExecutor ( {
193+ endpoint : 'http://localhost:4002/graphql' ,
194+ fetch : postsServer . fetch ,
195+ } ) ;
180196 subschemaConfig . executor = async function postsExecutor ( execReq ) {
181197 const result = await origExecutor ( execReq ) ;
182198 if ( process . env [ 'DEBUG' ] ) {
0 commit comments