I want to add the apollo framework to my iOS project. I'm following the documentation but can't build it.
- I install apollo via cocoapods
- I add a code generation build step to my target (put it above compile sources...)
- I download the schema via apollo schema:download --endpoint=http://localhost:4000/graphql schema.json. I add schema.json file to the root directory in my project.
I build it and get the following error:
- [email protected]
added 416 packages in 20.385s
++ exec /Users/PATH/node_modules/.bin/apollo codegen:generate --queries= --schema=schema.json API.swift
› Warning: apollo update available from 1.2.0 to 1.7.0
› Error: Flag --queries expects a value
Command /bin/sh failed with exit code 2
- [email protected]
added 416 packages in 20.385s
++ exec /Users/PATH/node_modules/.bin/apollo codegen:generate --queries= --schema=schema.json API.swift
› Warning: apollo update available from 1.2.0 to 1.7.0
› Error: Flag --queries expects a value
My schema.grapqhl file looks something like:
type Query {
""" User """
users: [User!]!
user(username: String!): User
""" Question """
questions: [Question!]!
question(id: Int!): Question
}
type Mutation {
""" User """
createUser(username: String!): User
updateUser(username: String!, newUsername: String!): [Int!]!
deleteUser(username: String!): Int!
""" Question """
createQuestion(text: String!, category: Int!, active: Boolean!):
Question
updateQuestion(id: Int!, text: String!, category: Int!, active: Boolean!): [Int!]!
deleteQuestion(id: Int!): Int!
}
type Subscription {
answerAdded: Answer
}
type Question {
id: Int!
text: String!
categoryId: QuestionCategory!
active: Boolean!
createdAt: String!
updatedAt: String!
}
......
It seems that the query param doesnt have an input: apollo codegen:generate --queries= --schema=schema.json API.swift
If i try it myself via terminal
apollo codegen:generate --queries=schema.graphql --schema=schema.json API.swift
I get the following error:
Warning: apollo update available from 1.2.0 to 1.7.0
.../schema.graphql: The Query definition is not executable.
.../schema.graphql: The Mutation definition is not executable.
.../schema.graphql: The Subscription definition is not executable.
.../schema.graphql: The Question definition is not executable.
... some more ...
:heavy_check_mark: Scanning for GraphQL queries (1 found)
:heavy_check_mark: Loading GraphQL schema
:heavy_check_mark: Parsing GraphQL schema
:heavy_multiplication_x: Generating query files with 'swift' target
→ Validation of GraphQL query document failed
ToolError: Validation of GraphQL query document failed
at Object.validateQueryDocument
....
Can you please help to find out why I can't build the project? Is it because my schema.graphl file is wrong?