im new in graphql, and what i want to achieve is simplify this schema:
input UserQueryFilter {
email: String
}
input UserQueryInput {
filter: UserQueryFilter
anotherArgs: String
}
type User {
email: String!
}
Query {
User (input: UserQueryInput) : [User]
}
into this:
input UserQueryFilter {
email: String
}
type User {
email: String!
}
Query {
User (input: { filter: UserQueryFilter }, anotherArgs: String ) : [User]
}
but i got :
Syntax Error: Expected Name, found "{".","locations":[{"line":183,"column":20}] ...
when it comes to more complex application, it will become easier to code on the second one. is there anything can do about it?
Thanks for your help!
The second schema is syntactically wrong. After a semicolon, always a Type will be expected. This type may be default types like String, ID, Int etc, or a custom type. Specifically for query params, it should be a default type or an Input type. Otherwise, as you mentioned, the buildSchema method will throw an error while parsing the entire schema.