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

GraphQL federation directives, which allow multiple values, do not match Apollo contract #30145

Closed
alexpoletaev opened this issue Jan 3, 2023 · 7 comments · Fixed by #30227
Closed
Labels
Milestone

Comments

@alexpoletaev
Copy link

Describe the bug

GraphQL federation directives, which allow multiple values, like @provides, @key, etc., do not match Apollo contract. It seems that in Apollo those directives have value of type FieldSet!, which represents whitespace-separated string of values, but Smallrye module represents those directives just as arrays of values. As a result, those directives are not valid for the Apollo server.

Expected behavior

The @provides directive is shown in the schema like that:
@provides(fields : "rating reviews")

Actual behavior

The @provides directive is shown in the schema like that:
@provides(fields : ["rating", "reviews"])

How to Reproduce?

Reproducer: quarkus-graphql-issue.zip

  • unzip a reproducer
  • start service
  • go to graphql UI
  • execute next query:
    query { _service { sdl } }
  • observe that @provides directive in the graphql schema has a type of array
  • uncomment a workaround method in the GraphQLSchemaObserver class
  • observe that @provides directive in the graphql schema has a type of whitespace-separated string (FieldSet)

Output of uname -a or ver

No response

Output of java -version

openjdk version "17.0.5" 2022-10-18

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.15.1.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 7.5.1

Additional information

This reproducer uses a workaround from the #30129 issue. It also provides a temporary workaround to convert @key and @provides directives from type of array to type of FieldSet (string).

@alexpoletaev alexpoletaev added the kind/bug Something isn't working label Jan 3, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 3, 2023

/cc @jmartisk(graphql), @phillip-kruger(graphql)

@jmartisk
Copy link
Contributor

jmartisk commented Jan 3, 2023

Here I think we will need the help of @t1 who wrote the code handling these directives -would you be willing to fix this in SmallRye?
It's an API breaking change, but since federation is marked experimental, it shouldn't be a huge deal

@t1
Copy link

t1 commented Jan 4, 2023

I'm taking a look into this. The problem is, that the @Key annotation then needs to be repeatable.

@jmartisk
Copy link
Contributor

jmartisk commented Jan 4, 2023

I think that repeatability would be great to have, but not strictly necessary, no?
As far as I understand, an annotation @Key(fields="a b") is equivalent to @Key(fields="a") plus @Key(fields="b")
The former translates to directive @key(fields: "a b"), the latter to @key(fields: "a") @key(fields: "b")

If we turn the fields parameter into a String that allows multiple values separated by spaces, it will be equivalent to having a repeated annotation for each value separately.

@jmartisk
Copy link
Contributor

jmartisk commented Jan 4, 2023

But right, there's also the resolvable parameter and if you want to have a different value of it for different fields, then we really need a repeatable annotation.

@t1
Copy link

t1 commented Jan 4, 2023

No, @Key(fields="a b") means you can resolve this with the combination of a and b... a compound key, so to speak, while @Key(fields="a") plus @Key(fields="b") means that you can resolve either with a or with b.

@jmartisk
Copy link
Contributor

jmartisk commented Jan 5, 2023

Ah, ok gotcha.

@quarkus-bot quarkus-bot bot added this to the 2.16 - main milestone Jan 9, 2023
@gsmet gsmet modified the milestones: 2.16 - main, 2.15.3.Final Jan 9, 2023
benkard added a commit to benkard/mulkcms2 that referenced this issue Jan 14, 2023
This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [io.quarkus:quarkus-maven-plugin](https://github.com/quarkusio/quarkus) | build | patch | `2.15.2.Final` -> `2.15.3.Final` |
| [io.quarkus:quarkus-universe-bom](https://github.com/quarkusio/quarkus-platform) | import | patch | `2.15.2.Final` -> `2.15.3.Final` |

---

### Release Notes

<details>
<summary>quarkusio/quarkus</summary>

### [`v2.15.3.Final`](https://github.com/quarkusio/quarkus/releases/tag/2.15.3.Final)

[Compare Source](quarkusio/quarkus@2.15.2.Final...2.15.3.Final)

##### Complete changelog

-   [#&#8203;30255](quarkusio/quarkus#30255) - Introduce a JSON Stream parser for the reactive rest client
-   [#&#8203;30242](quarkusio/quarkus#30242) - Throw an IllegalStateException with basic info about the provider that failed to provide a resource
-   [#&#8203;30227](quarkusio/quarkus#30227) - SmallRye GraphQL 1.9.1/2.0.1 + config property to control Federation
-   [#&#8203;30218](quarkusio/quarkus#30218) - OIDC documentation fixes
-   [#&#8203;30200](quarkusio/quarkus#30200) - Ensure that Kotlin implementation of QuarkusApplication works properly
-   [#&#8203;30195](quarkusio/quarkus#30195) - Log graphql.execution.AbortExecutionException when it occurs
-   [#&#8203;30190](quarkusio/quarkus#30190) - 2.15.2.Final breaks command mode with main class extends from QuarkusApplication in kotlin
-   [#&#8203;30187](quarkusio/quarkus#30187) - Bump xstream from 1.4.19 to 1.4.20
-   [#&#8203;30183](quarkusio/quarkus#30183) - Fixing typos in security overview doc
-   [#&#8203;30177](quarkusio/quarkus#30177) - Properly handle SSE comments in RESTEasy Reactive client and server code
-   [#&#8203;30172](quarkusio/quarkus#30172) - Codestarts - Fix flattening of log levels
-   [#&#8203;30169](quarkusio/quarkus#30169) - NullPointerException when sending SSE with comment only
-   [#&#8203;30161](quarkusio/quarkus#30161) - Align behavior for getDeferredIdentity and getIdentity in TestIdentityAssociation
-   [#&#8203;30160](quarkusio/quarkus#30160) - Different behavior in TestIdentityAssociation for getDeferredIdentity and getIdentity
-   [#&#8203;30157](quarkusio/quarkus#30157) - Gradle quarkusDev: don't use test classes dir for app classes
-   [#&#8203;30155](quarkusio/quarkus#30155) - Show how to verify smallrye-jwt issuer in a shared network
-   [#&#8203;30154](quarkusio/quarkus#30154) - Remove remaining references to javax classes
-   [#&#8203;30152](quarkusio/quarkus#30152) - Improve error handling of AbortExecutionException in smallrye-graphql extension
-   [#&#8203;30146](quarkusio/quarkus#30146) - Properly segregate Json MessageBodyReader/Writer classes for server and client
-   [#&#8203;30145](quarkusio/quarkus#30145) - GraphQL federation directives, which allow multiple values, do not match Apollo contract
-   [#&#8203;30142](quarkusio/quarkus#30142) - When disabling name and version for label selectod in k8s, don't remove from labels
-   [#&#8203;30138](quarkusio/quarkus#30138) - Keycloak Dev Services
-   [#&#8203;30132](quarkusio/quarkus#30132) - Register REST Client body parameters for reflection
-   [#&#8203;30119](quarkusio/quarkus#30119) - Enable/disable GraphQL Federation automatically (+ add a config property for it)
-   [#&#8203;30100](quarkusio/quarkus#30100) - Setting `add-version-to-label-selectors: false` removes the app.kubernetes.io/version label
-   [#&#8203;30078](quarkusio/quarkus#30078) - Quarkus Kotlin Native Reactive REST Client not working properly
-   [#&#8203;30061](quarkusio/quarkus#30061) - Adding Kotlin Tests Breaks Kotlin/Java project
-   [#&#8203;30044](quarkusio/quarkus#30044) - Resteasy Reactive Rest Client fails to re-construct large chunks of streamed json (stream+json) and fails deserialization
-   [#&#8203;29998](quarkusio/quarkus#29998) - Bump to smallrye-config 2.13.1
-   [#&#8203;29918](quarkusio/quarkus#29918) - smallrye-config: Converter<Int> throws IllegalStateException
-   [#&#8203;29609](quarkusio/quarkus#29609) - Remove Reflection replacements, now supported by GraalVM

</details>

<details>
<summary>quarkusio/quarkus-platform</summary>

### [`v2.15.3.Final`](quarkusio/quarkus-platform@2.15.2.Final...2.15.3.Final)

[Compare Source](quarkusio/quarkus-platform@2.15.2.Final...2.15.3.Final)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4yNC4wIiwidXBkYXRlZEluVmVyIjoiMzQuMjQuMCJ9-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants