Replies: 1 comment 3 replies
-
|
@ppesti thank you for bringing this up. We will look into it and get back to you. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am building a multi-purpose GraphQL service that can boot in different modes. It can be a book, an author, a course, or an assignment service, based on configuration in the application.yaml. This service is also can also be a subgraph for Apollo Federation, thus it uses directives such as @key and @external in the schema definition.
Up to this point, I had multiple schemas and only took advantage of one's functionalities. The problem with that was when I had my Book type defined in book.graphqls then the authorId: ID! field clashed with the one defined in author.graphqls, which was authorId: ID! @external. Let me demonstrate it a bit better...
book.graphqls:
type Book @key(fields: "id") @key(fields: "authorId") {
id: ID!
authorId: ID!
title: String!
isbn: String
pages: Int
yearOfPublication: Int
}
extend type Query {
books: [Book]
book(id: ID!): Book
}
author.graphqls:
type Author @key(fields: "id") {
id: ID!
name: String!
gender: String
nationality: String
}
extend type Book @key(fields: "authorId") {
authorId: ID! @external
author: Author
}
extend type Query {
authors: [Author]
author(id: ID): Author
}
This could be remedied by manually loading in the corresponding schema (and only that) at startup, though I haven't figured a way to do that. So I could have a directory containing all 4 schemas and just load the desired one based on the value in application.yaml.
If anyone knows how to achieve this, I would greatly appreciate your help!
Beta Was this translation helpful? Give feedback.
All reactions