question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting error deploying to Vercel : `Error: "Query" defined in resolvers, but not in schema`

See original GitHub issue

I’m trying to deploy a slightly modified version of the Next.js official graphql-let example and I’m getting this error Error: "Query" defined in resolvers, but not in schema.

So I’ve looked into lib/schema.ts and when adding some logs:

import { join } from 'path'
import { makeExecutableSchema } from '@graphql-tools/schema'
import { loadFilesSync } from '@graphql-tools/load-files'
import { mergeTypeDefs } from '@graphql-tools/merge'
import graphQLLetConfig from '../../.graphql-let.yml'
import resolvers from './resolvers'

const loadedFiles = loadFilesSync(join(process.cwd(), graphQLLetConfig.schema))
const typeDefs = mergeTypeDefs(loadedFiles)

console.log(`Loaded files:`);
console.log(loadedFiles);
console.log(`Graphql-let config schema`);
console.log(graphQLLetConfig.schema);
console.log(`Path ${process.cwd()}`);
console.log(`Join: ${join(process.cwd(), graphQLLetConfig.schema)}`)

export const schema = makeExecutableSchema({
  typeDefs,
  resolvers,
})

I’m getting this:

Loaded files:
[]
Graphql-let config schema
**/*.graphqls
Path /var/task
Join: /var/task/**/*.graphqls

Loaded files seems to be empty. An issue was opened last year https://github.com/piglovesyou/graphql-let/issues/214 regarding this error with SSR config but I’m running a Static config.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
marklawlorcommented, Aug 27, 2021

loadFileSync requires the files to be present on the Vercel filesystem at runtime. By default Vercel will only include the built files. You need to update your Vercel configuration to tell it to include these files.

The other option is not to use loadFileSync and instead use Webpack to load the files at build time. This way they are included in the built output

import { join } from 'path'
import { makeExecutableSchema } from '@graphql-tools/schema'
import { loadFilesSync } from '@graphql-tools/load-files'
import { mergeTypeDefs } from '@graphql-tools/merge'
import graphQLLetConfig from '../../.graphql-let.yml'
import resolvers from './resolvers'

import schema1 from "./schema1.graphqls"
import schema2 from "./schema2.graphqls"

const typeDefs = mergeTypeDefs([
  schema1,
  schema2
])

export const schema = makeExecutableSchema({
  typeDefs,
  resolvers,
})
0reactions
marklawlorcommented, Apr 12, 2022

I would create a new issue for that and include a reproduce-able demo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Query.Mutation defined in resolvers, but not in schema
I think you are simply missing a curly bracket. const resolvers = { Query:{ hello: () => 'Hello World', notes: () => notes,...
Read more >
Deploying with managed federation - Apollo GraphQL Docs
This ensures that resolvers are in place for all operations that are executable against your graph, and operations can't attempt to access fields...
Read more >
How to resolve 'X defined in resolvers, but not in schema' with ...
The root cause here is that the babel-plugin-inline-import plugin caches your schema. The resolution is essentially to have BABEL_DISABLE_CACHE=1 in your . env ......
Read more >
GraphQL | RedwoodJS Docs
You define your SDLs (schema) in *.sdl.js files, which define what queries and mutations are available, and what fields can be returned; For...
Read more >
Why does my Serverless Function work locally but not when ...
It can be frustrating when your code works locally, but not when deployed to ... eyes on your problem, consider starting a Discussion...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found