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

Example with fragments #65

Closed
bdombro opened this issue Mar 4, 2020 · 13 comments · Fixed by #141
Closed

Example with fragments #65

bdombro opened this issue Mar 4, 2020 · 13 comments · Fixed by #141
Labels
enhancement New feature or request

Comments

@bdombro
Copy link

bdombro commented Mar 4, 2020

I tried for a while to get fragment to work and failed. Are they supported? If so, can you extend your reference application to demonstrate?

@piglovesyou
Copy link
Owner

Hello @bdombro, thank you for using graphql-let.

Sadly, It seems that independent .graphql document files don't have measures to import another GraphQL document right now, as you investigated.

A thread says the spec still needs time to be standardized for a concrete syntax. I think we should wait for something #import or #include they're discussing.

@bdombro
Copy link
Author

bdombro commented Mar 9, 2020

Bummer! But looking at the Apollo docs, isn't import already settled and adopted? Ref: https://www.apollographql.com/docs/react/integrations/webpack/#fragments

@piglovesyou
Copy link
Owner

@bdombro Yeah it is in webpack for now. But... as I looked at graphql-import, we might be able to load *.graphql just by it. Let me try it.

@piglovesyou piglovesyou added the enhancement New feature or request label Mar 10, 2020
@piglovesyou
Copy link
Owner

piglovesyou commented Mar 10, 2020

Progress

  • graphql-import is for schema, not for documents so it's not our option
  • graphql-tag/loader beautifully loads subsequent dependencies by #import "a.graphql"
    • by webpack loader. Since we provide graphql-let CLI, we can't use it directly
  • graphql-tag function (gql()) generates documents AST, but it doesn't include information of #import
  • I found webpack/loader-runner. Perhaps we can share how to load files by both CLI and Loader, while it differs in file processing steps depending on the context? That allows graphql-tag to load .graphql including #import

@bdombro
Copy link
Author

bdombro commented Mar 15, 2020

Exciting you've made progress! I wish I had more to contribute -- I know little about the inner workings of Apollo at this point. Someday that will hopefully change. I can tell ya though that fragments are very important to my colleagues.

@ardatan
Copy link

ardatan commented Jun 19, 2020

@piglovesyou GraphQL Tools supports #import for both schema and documents. It's not documented specifically yet but it does all those stuff with @graphql-tools/import under the hood.
https://www.graphql-tools.com/docs/documents-loading

@piglovesyou
Copy link
Owner

Thanks for the information! I didn't check it last time, so that might be what we've looked for.

@piglovesyou
Copy link
Owner

piglovesyou commented Jul 31, 2020

I made sure it solves the problem with your amazing work, thank you @ardatan ! The rest I need is time to code👍

@bdombro
Copy link
Author

bdombro commented Aug 8, 2020

@piglovesyou thanks for you're hard work! Curious, this ticket is for an example -- can you point me to an example of it working? Would love to see it in the awesome nextjs example. I'll try to add when I can find time.

@piglovesyou
Copy link
Owner

Thank you @bdombro! @graphql-tools/import is the trick. For a quick answer,
This imports this fragment. Here describe a little more. Yes, it's been a while to put features into with-typescript-graphql, it's great if you find the time :)

@bdombro
Copy link
Author

bdombro commented Aug 8, 2020

I forked nextjs, created a branch, and updated the example but it's not working with Fragments. Could you take a look? I added you as a collaborator so feel free to fix and push directly to the branch @piglovesyou

https://github.com/bdombro/next.js/tree/with-typescript-graphql-update/examples/with-typescript-graphql

@piglovesyou
Copy link
Owner

piglovesyou commented Aug 8, 2020

Because I didn't publish 0.15.0 yet. I'd like to add one more feature so please wait for a moment. Thank you!

@mcabrams
Copy link

mcabrams commented Aug 26, 2021

Any update on when this may be supported? I see the issue is closed, but the README still links here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants