im trying to get the types defined in my Apollo server
by first, downloading the schema effectively:
apollo client:download-schema src/code/queries/schemas/schema.json --endpoint http://localhost:4000/
that command generates the following .json, reduced it for demonstration purposes.
{
"__schema": {
"queryType": {
"name": "Query"
},
"mutationType": {
"name": "Mutation"
},
"subscriptionType": null,
"types": [
{
"kind": "OBJECT",
"name": "Query",
"description": null,
"fields": [
{
"name": "UserInformation",
"description": null,
"args": [],
"type": {
"kind": "OBJECT",
"name": "User",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "User",
"description": null,
"fields": [
{
"name": "firstName",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "secondName",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null..........
then tying to generate the types as typescript without success:
apollo client:codegen --target typescript --localSchemaFile src/code/queries/schemas/schema.json --outputFlat src/code/queries/generated
the globalTypes.ts is generated empty (only comments)..
You need to include the --includes
option to indicate which files contain the actual queries for which to generate the types. From the docs:
--includes=includes Glob of files to search for GraphQL operations. This should be used to find queries and any client schema extensions