Open gio-shara-code opened 1 year ago
Solution
Okay, apparently this library does not like when you don't have mutation resolvers at all. For some reason it throws the above described error, because I did not implement at least one mutation throughout schemas...
extend type Query {
book(id: ID!): Book
}
extend type Mutation {
markBookAsRead(id: ID!): Book! # added this mutation and generated types.
}
type Book {
id: ID!
isbn: String!
}
Hi @gio-shara-code,
You are right about the extend type Mutation
π
It looks like the preset's not validating and throwing error if the schema is invalid.
I think in this case, there are one of two ways (one of which you covered):
type Mutation
extend type Mutation
with at least one field (Your solution)I think the solution here is to for the preset to see validate the parsed schema. Thanks for reporting the issue and the solution! π
(Note that codegen will validate the schema when running plugins if the documents
option is set. However, we don't usually set this option when generating server types... so it could be a problem if we generate server type without the preset too)
I was getting this exact same error but had declared both at least 1 Mutation and 1 Query. Turns out I accidentally added the extends
keyword in front of one of my schema types. Seems like this should fail on code generation instead of attempting to validate the schema with invalid type defs when there is no schema type to extend.
Isnt the primary issue here, that the typedefs dont set the source
element, so the graphql/language/location.js
breaks?
At least for me, that seems to be the biggest hurdle, because it is hiding the underlying schema problem
I'm running into this issue, but the proposed solution is actually not working for me. In fact, it seems when I do create Mutations is when it breaks. If can have a set of schemas with the base/schema.graphql
having type Mutation
commented out and the extend type Mutation
commented out in my various other queries and it works, but as soon as I uncomment the type Mutation
and any of the extend type Mutation
then the whole thing breaks.
@tenpaiyomi Having the same issue as you. Did you figure out how to solve this?
@tenpaiyomi I had a silly mistake with my mutation, was using a type as an input to my mutation which doesn't work π€¦πΌ Works fine now. Maybe you have some mistake with one of your mutations too?
@theomessin how silly, literally what happened to me too π perhaps more meaningful errors might be helpful
Hi all, thanks for reporting this, I'll take a look soon to see what the best solution is π
Describe the bug I am following this article here: https://the-guild.dev/graphql/codegen/docs/guides/graphql-server-apollo-yoga-with-server-preset. I want to generate resolver and schema types (
typedefs
) with the following library:@eddeee888/gcg-typescript-resolver-files
. Schema and resolver type generation works fine, but when I am trying to run the apollo server with the generatedtypedefs
it throws and error (See error below). The error is thrown from the following path:graphql@16.6.0/node_modules/graphql/language/location.js:23
to be more precise this function throws itgetLocation
.Would appreciate your help, thanks.
To Reproduce _Steps to reproduce the behavior: _1. Create apollo server 4 _2. Create sample graphql query _3. Generate types using
@eddeee888/gcg-typescript-resolver-files
_4. Pass generatedresolvers
andtypedefs
to the server. _5. Run the serverExpected behavior Should be running server smoothly without throwing the error (see below)
Versions
Additional context Minimal code below:
Error message:
Note: I am using the exact same folder structure as in the documentation.