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

Expose types for interface/union types #72

Open
arnarthor opened this issue Feb 26, 2019 · 0 comments
Open

Expose types for interface/union types #72

arnarthor opened this issue Feb 26, 2019 · 0 comments

Comments

@arnarthor
Copy link

arnarthor commented Feb 26, 2019

I have query which looks something like this

        query FeedQuery {
          feed {
            title
            ... on Picture {
              url
              description
            }
            ... on Video {
               length
            }
          }
        }

Which has the return type

{. "feed": [ 
  | `Picture({. "title": string, "url": string, "description": string}) 
  | `Video({. "title": string, "length": int}) ]
}

Would it be possible to expose the type of the polymorphic variant here instead of inlining it.
My use case is that I have a subscription and a query fetching the same things, and I don't want to store these things as a Js.t({. "feed": ...}) but instead extract the actual variant types and store those as a list in my app.

I first fetch the feed from the query, and then use subscriptions to update the feed by injecting new objects. Having a list of the above mentioned Js.t is way more awkward than just storing a list of the actual variant.

I'm okay with converting between the subscription and query types since they won't be the same thing. But not having to extract it first from a Js.t would help a lot.

ylecornec pushed a commit to o1-labs/graphql_ppx that referenced this issue Jun 3, 2022
* fix: drop env based configuration
* fix: drop env based configuration in favor of ppx-flags based
* Lean parse (mhallin#58)
* Simplify decoders
* Simplify
* make it even more efficient
* Add config option
* add feature flag
* make it work
* Make tests pass
* Test lean parse by default
* Remove Js.Dict.get runtime overhead
* remove comment
* fix enums
* remove comment
Co-authored-by: Jaap Frolich <jfrolich@gmail.com>
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

1 participant