apollographql / apollographql/federation

Error: Expected undefined to be a GraphQL schema.

Open
#1,102 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
725
Forks
276
Avg merge
1h 47m
Merged PRs (30d)
1

Description

const { ApolloServer } = require('apollo-server')
const { ApolloGateway } = require('@apollo/gateway')
const { get,post } = require('httpie')
const { readFileSync } = require('fs');

async function getSupergraph() {
let res = await get(`http://localhost:4007/graph`)
return {
supergraphSdl :res.data
};
}

async function startServer() {
const gateway = new ApolloGateway({
experimental_pollInterval: 3000,
experimental_updateSupergraphSdl: async(config) => {
return getSupergraph()
},
__exposeQueryPlanExperimental: false,
})

const server = new ApolloServer({
gateway,
engine: false,
subscriptions: false,
})

server.listen({ port: 4008 }).
then(({ url }) => console.log(`🚀ApolloGateway app running at ${url}`))
.catch(err => {console.error(err)});
}

startServer().catch((err) => {
console.error(err)
process.exit(1)
})

________________
ERROR
________________
Error: Expected undefined to be a GraphQL schema.
at assertSchema (C:\Users\grevant3\Desktop\HUHU\node_modules\graphql\type\schema.js:47:11)
at validateSchema (C:\Users\grevant3\Desktop\HUHU\node_modules\graphql\type\validate.js:42:28)
at assertValidSchema (C:\Users\grevant3\Desktop\HUHU\node_modules\graphql\type\validate.js:66:16)
at assertValidExecutionArguments (C:\Users\grevant3\Desktop\HUHU\node_modules\graphql\execution\execute.js:150:35)
at executeImpl (C:\Users\grevant3\Desktop\HUHU\node_modules\graphql\execution\execute.js:98:3)
at execute (C:\Users\grevant3\Desktop\HUHU\node_modules\graphql\execution\execute.js:60:35)
at generateSchemaHash (C:\Users\grevant3\Desktop\HUHU\node_modules\apollo-server-core\dist\utils\schemaHash.js:15:44)
at ApolloServer.generateSchemaDerivedData (C:\Users\grevant3\Desktop\HUHU\node_modules\apollo-server-core\dist\ApolloServer.js:333:64)
at SchemaManager.schemaDerivedDataProvider (C:\Users\grevant3\Desktop\HUHU\node_modules\apollo-server-core\dist\ApolloServer.js:107:65) at SchemaManager.processSchemaLoadOrUpdateEvent (C:\Users\grevant3\Desktop\HUHU\node_modules\apollo-server-core\dist\utils\schemaManager.js:100:103)

getSupergrap() will return the supergraphSdl string of the managed subgraphs

Contributor guide

Open the contributing guide

Research direction

Start with the ApolloGateway experimental_updateSupergraphSdl configuration and the ApolloServer gateway initialization shown in the reproduction, then run the supplied server example to observe when the schema error occurs. Done means the gateway starts successfully and accepts the polled supergraph SDL without reporting that the schema is undefined.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, javascript, node.js, typescript
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.