-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The Schema validation/merge is broken #453
Comments
A second possible problem I found with Literal comments do get transformed into Example: """
This comment will remain and be converted to #
"""
type Query {
}
# This comment will disappear
type mutation {
} result # This comment will remain and be converted to #
type Query {
}
type mutation {
} We should probably support "old style" comments |
@bboure I will see if the new grapgql.js supports merging types the old way, without the extends keyword. Keeping the comments should be quick, I'll do some tests for both in the weekend. |
Let me explain a bit more on the schema merging behavior, and how I am planning to solve this. The Conflicting Approaches
# User.graphql
type User {
id: ID!
username: String!
}
type Query {
users: [User!]!
} # Article.graphql
type Article {
id: ID!
author: User!
content: String!
}
type Query {
articles: [Article!]!
} This method does NOT support the
# root.graphql
type Query
type Mutation # User.graphql
type User {
id: ID!
username: String!
}
extend type Query {
users: [User!]!
} # Article.graphql
type Article {
id: ID!
author: User!
content: String!
}
extend type User {
articles: [Article!]!
}
extend type Query {
articles: [Article!]!
} The Solution
What do you think? |
I also had a look at this yesterday. I used a similar approach. The way I got it to work (I think)was using the old behaviour first with I need to read more doc and code and see what is the "recommended" usage for "schema stitching". |
I think the best option is to support both versions at the same time. You may make the final call on whether to force a choice behind an option, or simply support both ways with my proposed solution. I am sharing the pieces of backstories I have learnt below, along with some of my opinions. People coming from the Apollo ecosystem maybe confused by the legacy syntax in AppSync, and there are people started small from the Amplify toolchain. The community is fragmented. I have read comments from many people about rooms for improvements from the GraphQL spec governance, all the way to the fact that AppSync refuses to catch up with it.
Apollo is trying so hard to get people to pipe their production data to their platform, see Apollo Engine, Apollo Studio (adapted from GraphiQL), and their latest boy, Schema Federation. I think this makes schema stitching less of an incentive to be advertised and promoted. While With the current situation, I think it is unlikely for AppSync to support newer version of specs without introducing something new, similar to API Gateway V2 (HTTP API) vs the original API Gateway (REST API). If by any means possible, I'd love to see this plugin embraces both sides of an otherwise unfortunately fragmented user base. |
The idea would to support both ways: either use "standard" graphql or "the AppSync way" (with # descriptions, and ", " separators) The problem is that the tooling does not support AppSync schemas and it's hard to work with it in the plugin. eg: for validation, stitching, etc By default, I would advocate for using "standard" GraphQL and "translate" under the hood. |
If we are going the direction of either-or, I can make a PR to introduce a new option For now it defaults to the legacy way for backward compatibility, we can change the default for the next major release. |
I have been investigating this yesterday for a while and I think there is no easy fix to this. Here are my findings: It looks like AppSync now handles schemas better:
I contacted the AppSync team and it looks like they are working on improving this even further. Also, mergeTypeDefs transforms Given this, in order to solve your issue (accept """ descriptions), I suggest that we fix this the following way in v1.
I tested this and it works. This is the solution that has the less impact on compatibility In v2 I suggest the following:
If we do the above and hope that AppSync catches up with the standards soon enough, we would not need to change almost anything to the implementation and I don't think there would be any breaking change. LMK what you think or if I missed something. Thanks Edit: I think the idea would be to enforce modern schemas in v2. (e.g.: NOT accept "," for interfaces). |
Since #437, the schema validator and merger is broken.
The following errors started appearing:
The reason is that multiple files define
Query
andMutation
Example:
Expected result:
Schema gets converted to
What happens instead:
The above error.
@vicary
The text was updated successfully, but these errors were encountered: