My type definition is like this
type COMPANY {
"AIRLINE SEGMENT": String
AIRLINE_TYPE: String
}
I get an error saying
apollo server GraphQLError: Syntax Error: Expected Name, found :
If I remove the space and quotes then I don't get an error. I have searched everywhere but I haven't a way to add names with spaces in them.
Any help will be highly appreciated. Thanks.
GraphQL does not support spaces within names. According to the spec, names must match the following regular expression:
GraphQL actually ignores all white space within a document, with the exception of white space within Strings and Comments:
You probably shouldn't be using spaces within node names in the first place, even if they are technically supported. This is the recommended naming convention:
If your data source returns an object with fields whose names include spaces, you can convert these to "legal" field names inside your resolver map. For example, given a type named
Company
with a field calledairlineSegment
: