You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given I have generated a server schema.json file using:
apollo schema:download \
app/javascript/src/graphql/schema.json \
--endpoint="http://localhost:3000/api/graphql" \
--header="Authorization: Bearer ${accessToken}"
And I have also generated a client schema.json file using:
apollo schema:download \
app/javascript/src/graphql/client/schema.json \
--endpoint="app/javascript/src/graphql/client/schema.gql"
Both of which produce a schema.json file that seems correct to the naked eye.
Here is the client/schema.gql file:
type Gui {
fontSize: Int
isHighContrast: Boolean
}
type Person {
isOnline: Boolean <-- both server and client and this prop uses the `@client` directive within the Person.gql fragment
}
type Mutation {
updateGui(input: Gui): Gui
}
type Query {
gui: Gui
}
The real issue comes when I try to generate types using:
apollo codegen:generate \
app/javascript/src/constants/types.ts \
--clientSchema="app/javascript/src/graphql/client/schema.json" \
--outputFlat \
--schema="app/javascript/src/graphql/schema.json"
I get an error in the resolveSchema method in apollo/lib/config.js: Cannot read property 'extends' of undefined. Possibly related is this issue #510 and subsequent PR #511, but not fixed in version 1.7.0. This error is due to the fact that the schemas node of the config has been transformed to this:
Notice how the keys have been updated client => default and main => serverSchema. Now when it's trying to create the referredSchema variable while mapping over config.queries it can't find the provided schema values from the query (client or main) since they are no longer in the structure of what the config.schema is within the resolveSchema method. Based on the readme I would have imagined that the key config.queries[0].schema would match the structure passed from the config.schema object and not get mutated at some point, in this case being either client or main key values.
Knowing this I can "hack" the config to get past the above issue using the following config:
Notice how I changed the keys from client => default and main => serverSchema, which now gets me to a different error: Must provide valid Document AST within the graphql package's extendSchema function. The only input path passed to this method is the config.schemas.schema file, which is json and not supported by extendSchema. I would have thought that the array of files from config.queries.includes would have been passed to this and then compared later against both the client and server schema.json files for generating type information.
I've tried defining the queries within the schemas themselves as in the config below, but still get the same error Must provide valid Document AST.
I've also created an executable schema for the client via makeExecutableSchema from the graphql-tools package, so I can see my client query and mutation in the apollo client developer tools extension. I feel like I've dotted my i's and crossed my t's, but after debugging for a couple of days I might have exhausted my efforts. I can provide additional info as needed.
Any help would be greatly appreciated 🤘
The text was updated successfully, but these errors were encountered:
Ran into the same issue where I was having trouble using both server and client schema: I found the solution here to be helpful: apollographql/rover#494
I'm using
apollo
version 1.7.0Given I have generated a server
schema.json
file using:And I have also generated a client
schema.json
file using:Both of which produce a
schema.json
file that seems correct to the naked eye.Here is the
client/schema.gql
file:The real issue comes when I try to generate types using:
In
package.json
given the config:I get an error in the
resolveSchema
method inapollo/lib/config.js
:Cannot read property 'extends' of undefined
. Possibly related is this issue #510 and subsequent PR #511, but not fixed in version 1.7.0. This error is due to the fact that theschemas
node of the config has been transformed to this:Notice how the keys have been updated
client
=>default
andmain
=>serverSchema
. Now when it's trying to create thereferredSchema
variable while mapping overconfig.queries
it can't find the provided schema values from the query (client
ormain
) since they are no longer in the structure of what theconfig.schema
is within theresolveSchema
method. Based on the readme I would have imagined that the keyconfig.queries[0].schema
would match the structure passed from theconfig.schema
object and not get mutated at some point, in this case being eitherclient
ormain
key values.Knowing this I can "hack" the config to get past the above issue using the following config:
Notice how I changed the keys from
client
=>default
andmain
=>serverSchema
, which now gets me to a different error:Must provide valid Document AST
within thegraphql
package'sextendSchema
function. The only input path passed to this method is theconfig.schemas.schema
file, which isjson
and not supported byextendSchema
. I would have thought that the array of files fromconfig.queries.includes
would have been passed to this and then compared later against both the client and serverschema.json
files for generating type information.I've tried defining the
queries
within theschemas
themselves as in the config below, but still get the same errorMust provide valid Document AST
.Other notes:
I've also created an executable schema for the client via
makeExecutableSchema
from thegraphql-tools
package, so I can see my client query and mutation in the apollo client developer tools extension. I feel like I've dotted my i's and crossed my t's, but after debugging for a couple of days I might have exhausted my efforts. I can provide additional info as needed.Any help would be greatly appreciated 🤘
The text was updated successfully, but these errors were encountered: