We are currently working on developing micro-services using NestJS with TypeScript, where each service exposes a GraphQL schema. To combine these schemas into a single graph, we have implemented a federation service within NestJS.
During the integration process with '@graphql-eslint/eslint-plugin', I encountered some unexpected exceptions:
The error message "Unknown directive "@key"" was being thrown.
Fortunately, I was able to resolve these errors by following a discussion on GitHub: https://github.com/cjoudrey/graphql-schema-linter/issues/210
I then created a new file containing type specifications based on the Apollo documentation guidelines: https://www.apollographql.com/docs/federation/federation-spec/#federation-schema-specification
Despite resolving the initial issue, I am now facing additional errors that I am unfamiliar with and unsure how to address:
The parsing error states: "Cannot extend type "Query" because it is not defined. Did you mean "User"?".
It also mentions: "Cannot extend type "Mutation" because it is not defined."
Additionally, there are errors indicating: "Unknown type "Query". Did you mean "User"?", and "Unknown type "Mutation".".
Sharing a snippet of my schema for reference:
extend type Query {
users: [User]
user(email: EmailAddress!): User
}
extend type Mutation {
createUser(userData: UserData!): User
}
type User @key(fields: "email") {
email: String!
name: String
}
input UserData {
email: String!
name: String
}
If anyone has insights on why these errors are occurring or how to resolve them, your input would be greatly appreciated.