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

Bug: API Objects with a Single Scalar Field Are Interpreted As Scalars #270

Closed
sherl0cks opened this issue May 29, 2020 · 3 comments
Closed

Comments

@sherl0cks
Copy link

sherl0cks commented May 29, 2020

This may be related to the use of Kotlin data classes in my code.

For the following API and model

@GraphQlClientApi(endpoint = "https://api.com/graphql")
interface Client {
    fun query(foo : String): Response
}

data class Project( var apiObject : ApiObject)

data class ApiObject(
    var id: String = "",
    var name: String = "" // This second field must be added or graphql client thinks that `Project` is a `String` due to its "scalar constructor"
) 

In this case, if ApiObject only has id, graphql request with be apiObject, instead of apiObject{ id }. Adding a second field will result in apiObject{ id name }

Seems caused by this chain:

Stream.of(getRawType().getConstructors()).filter(this::hasOneStringParameter))

@phillip-kruger
Copy link
Member

@t1 any thoughts ?

@t1
Copy link
Collaborator

t1 commented May 31, 2020

I think this is exactly what we discussed in eclipse/microprofile-graphql#251: a single-string constructor is currently considered as defining a custom wrapper class.

I will do a change for that case in the client.

@phillip-kruger
Copy link
Member

Yea this was my worry in applying that by default. I think we need to apply this with some annotation so that it's a more explicit decision from the user.

phillip-kruger added a commit that referenced this issue Jun 1, 2020
fix #270: don't assume String-only constructors to define a scalar wrapper
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

No branches or pull requests

3 participants