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

Standalone type parsers #15

Open
wokalski opened this issue Jan 4, 2018 · 2 comments
Open

Standalone type parsers #15

wokalski opened this issue Jan 4, 2018 · 2 comments

Comments

@wokalski
Copy link
Contributor

wokalski commented Jan 4, 2018

It'd be useful to have standalone type parsers so that one can define such parser wherever they want to parse an object of a given GraphQL type. I took a very simple approach of generating a parser for a type name in #14 . It was promising however it yielded huge objects which took forever to compile.

Later I thought about using type names for simple types and inline fragments for objects. It's not ideal since we might want to generate a recursive parser however I think it's good enough for most use cases. Generating such parsers should not be too challenging. For simple types one could take the approach from #14 and for Objects it's possible to parse the fragment using Document.inline_fragment and then call directly to unify_selection_set. The second case involves some internal refactorings but should be pretty straightforward.

@baransu
Copy link
Contributor

baransu commented Apr 3, 2019

@wokalski What would be the case of such parsers for other case than scalars? Can you provide some use case?

For me, it would be useful to be able to provide parsers for custom scalar types like Long used by Sangria server. I had a few cases when Js.Json.t was handled incorrectly producing runtime errors. One place to define such would be much better.

@wokalski
Copy link
Contributor Author

wokalski commented Apr 4, 2019

@baransu to be honest I don't remember what was the use case I had when I experimented with it. The premise was to be able to take an existing GraphQL type from the schema, say SomeType and do something along these lines:

let parser = [%graphql.parser "[SomeType!]!"]
let listOfSomeTypeObjects = parser(somejson)

ylecornec pushed a commit to o1-labs/graphql_ppx that referenced this issue Jun 3, 2022
* fix: probably fix windows build

* fix: build

* Rename nodejs.yml to test.yml

* Update and rename test.yml to main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update CI

* fix: esy build

* fix: disable windows build

* fix: reorder workflow

* fix: typo

* fix: try to fix

* fix: try to figure out env variables

* ci: another attempt

* another ...

* another ...

* try release

* fix: copy :P

* fix: copy :P

* ci: another fix

* feat: try release

* feat: remove travis ci

* chore: remove traivis badge

* ci: run release job only on release

* ci: fix

* ci: remove pull_request trigger

* ci: pin menhir version for windows build

* ci: pin menhir version for windows build

* ci: make windows work

* ci: fix setting env in windows

* ci: windows ....

* ci: remove old ci stuff

* ci: install cross-env global for windows

* fix: improve publish step

* fix: try make windows work again pliz

* fix: windows doesn't like comments :/

* fix: windows ci

* fix: another one for windows :/

* ci: change name
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

2 participants