graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

Uri deserialization should support relative URIs

Open gregsdennis opened this issue 7 months ago • 0 comments

Product

Strawberry Shake

Version

13.9.4

Link to minimal reproduction

https://github.com/json-everything/json-everything/blob/637895947c44a376b13b4019256b6da1316773e2/tools/GenerateSponsorList/Program.cs#L27

Steps to reproduce

Query against GitHub API:

query {
  user(login:"<username>") {
    ... on Sponsorable {
      sponsors(first: 10) {
        nodes {
          ... on User {
            websiteUrl
          }
          ... on Organization {
            websiteUrl
          }
        }
      }
    }
  }
}

You need a sponsor who's URL is relative, like mysite.io. Apparently GH accepts that.

I can't create a reproduction because it requires authenticated data. The reproduction link I've supplied is the point at which my app fails.

What is expected?

I expect the response to deserialize.

Uri.TryCreate() successfully makes a relative URI.

What is actually happening?

Apparently one of my sponsors has entered a URL like mysite.io as their website, and the ILeafValueParser<Uri> that's generated seems to have a hard time parsing it. Seems it interprets this as a relative URI and expects it to start with a slash.

Exception is GraphQLClientException with this as the message:

The relative uri mysite.io does not start with '/'

Relevant log output

No log output.

Additional context

Per @michaelstaib (in Slack) the serializer is https://github.com/ChilliCream/graphql-platform/blob/main/src/StrawberryShake/Client/src/Core/Serialization/UrlSerializer.cs

gregsdennis avatar Jun 28 '24 23:06 gregsdennis