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

Urql support #1814

Merged
merged 6 commits into from
May 7, 2019
Merged

Urql support #1814

merged 6 commits into from
May 7, 2019

Conversation

mxstbr
Copy link
Contributor

@mxstbr mxstbr commented May 6, 2019

I mainly just copied the react-apollo plugin and rewrote the generated code to use the urql API, which differs from the react-apollo and react-apollo-hooks a bit.

  • Generate hooks
  • Generate components
  • Fix options
  • Test whether generated code actually works

Closes #1575

Implements hooks support for FormidableLabs/urql users.

Ref dotansimha#1575
@mxstbr mxstbr changed the title Initial urql support (only hooks) Urql support May 6, 2019
@mxstbr
Copy link
Contributor Author

mxstbr commented May 6, 2019

Testing this in our project, this fails because Urql.Use<Query|Mutation|Subscription>Args is not exported from urql. /cc @kitten

@mxstbr
Copy link
Contributor Author

mxstbr commented May 6, 2019

Blocked by urql-graphql/urql#235, otherwise this is almost ready pending some cleanup

That PR was merged, this is basically ready! Note that I have only tested hooks in our project, as we don't use any components.

@dotansimha
Copy link
Owner

dotansimha commented May 6, 2019

@mxstbr that's looks great.
Note that the base client-side also has configuration for noGraphQlTag that precompile the GraphQL operations into a DocumentNode during generation, so I think we need to make sure it's compatible with urql (I guess it should work, but worth a check).

@mxstbr
Copy link
Contributor Author

mxstbr commented May 6, 2019

Note that components support currently fails with this error:

TypeScript error: Type '{ variables: QueryVariablesName; requestPolicy?: "cache-first" | "cache-only" | "network-only" | "cache-and-network" | undefined; query: any; }' is missing the following properties from type 'QueryHandlerProps': client, children, key  TS2739

I am not sure how to resolve that. It's caused by Urql.Query expecting more props than we provide to the custom components.

@mxstbr
Copy link
Contributor Author

mxstbr commented May 6, 2019

Fixed component generation in the latest commit, pending the publication of a new version of urql with this patch applied urql-graphql/urql#236 this works great! 💯

@dotansimha this should be ready to ship?!?!

@dotansimha
Copy link
Owner

Thanks @mxstbr ! Looks great.
(btw, you can test and use it now, before the next stable release, because we are publishing an alpha version per each commit)

@dotansimha dotansimha merged commit bac0e05 into dotansimha:master May 7, 2019
@mxstbr mxstbr deleted the urql-support branch May 7, 2019 06:05
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

Successfully merging this pull request may close these issues.

Add new template or config option to apollo-react to support urql
2 participants