Skip to content
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

[apollo-ast] Add GQLDocument.validate(SchemaValidationOptions) to allow adding external schemas. #6164

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

martinbonnin
Copy link
Contributor

Also add support for kotlin_labs/v0.4

val cacheControlSchema = ForeignSchema("cache", "v0.1", definitions)

schemaString.toGQLDocument().validateAsSchema(
    SchemaValidationOptions(
        addKotlinLabsDefinitions = false,
        foreignSchemas = listOf(cacheControlSchema)
    )
).getOrThrow()

…ernal schemas.

Add support for kotlin_labs/v0.4
Copy link

netlify bot commented Sep 26, 2024

Deploy Preview for apollo-android-docs canceled.

Name Link
🔨 Latest commit 72fb98d
🔍 Latest deploy log https://app.netlify.com/sites/apollo-android-docs/deploys/66f58340cb0a8c0008aa2ac5

Copy link
Contributor

@BoD BoD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

)
)
} else {
issues.add(OtherValidationIssue("Apollo: unknown foreign schema '$foreignName/$foreignVersion'", gqlDirective.sourceLocation))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey actually, maybe this should be allowed? In my case, the cache gradle plugin can add the cache foreign definitions 👍 - but users will still also apply the regular apollo gradle plugin, which won't accept the extend schema @link(url: "https://specs.apollo.dev/cache/v0.1" import: ...) with this check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes. Good point. I still think this is something we want to validate. For an example, someone asking for nullability/v0.1 support should get an error: this is not supported anymore.
Yet another argument for a plugin API. Schema validation should be done only once. But plugins could contribute foreign schemas. I'll open a separate PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up PR #6165

@martinbonnin martinbonnin merged commit df6ab99 into main Sep 30, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants