Yes. This is a perfectly acceptable way of doing it although your example is maybe a bit less perfect. Consider something like this though:
# employee.graphql
type Employee {
id: ID!
name: String!
}
# company.graphql
type Company {
id: ID!
name: String!
}
extend type Employee {
company: Company! @belongsTo
}
The loginCount
attribute in your example did not seem related to the company.graphl
, so for your own sanity try to keep related items grouped.
But having all company related fields and queries in a single file makes a lot of sense especially on bigger schema's.
One sidenote, the added field (loginCount
in your example and company
in mine) is added to the Employee
type wherever you are using it, it's not like that added field is only available within company.graphql
. When building the final schema all extend *
types are merged together to a single Employee
type so the end result of the above results in this schema:
type Employee {
id: ID!
name: String!
company: Company!
}
type Company {
id: ID!
name: String!
}
Hope it all makes sense!