4

I am trying to integrate apollo iOS client and after doing all steps I am getting the error while running build phase script. so there are three errors in total. one is

  1. Error initializing Apollo GraphQL project "Unnamed Project".
  2. Error: Error in "Loading schema for Unnamed Project".
  3. TypeError: Cannot read property 'reduce' of undefined at Object.error.

Note this accuring inside node_modules/@oclif.

Error initializing Apollo GraphQL project "Unnamed Project": Error: Error in "Loading schema for Unnamed Project": TypeError: Cannot read property 'reduce' of undefined

M Faheem Rajput
  • 768
  • 2
  • 9
  • 27

2 Answers2

6

I think you need to check schema.json file inside your project, i have also faced same issue and same error but solved by adding schema.json file inside project directory

You can download it by below command

apollo schema:download --endpoint=http://localhost:8080/graphql schema.json
Mayur Tanna
  • 361
  • 4
  • 9
1

first you should add this command npx apollo service:download --endpoint= schema.json

then run this command npx apollo codegen:generate --localSchemaFile=graphql-schema.json --target=typescript --tagName=gql

  • 1
    Please describe why these command resolve the issue? – sorosh_sabz Oct 06 '21 at 20:16
  • Thank you, this helped me. I had already linked the schema URL and it kept throwing errors for some reason. When I executed below lines, it worked like a charm for me. npx apollo service:download --endpoint= graphql-schema.json – ShrawaniSilwal Nov 11 '21 at 15:24