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

🐛 Nested fragments don't work with @client directive #10003

Closed
AndreyCashia opened this issue Aug 12, 2022 · 6 comments · Fixed by #10560
Closed

🐛 Nested fragments don't work with @client directive #10003

AndreyCashia opened this issue Aug 12, 2022 · 6 comments · Fixed by #10560
Labels

Comments

@AndreyCashia
Copy link

AndreyCashia commented Aug 12, 2022

Intended outcome:

I want to get my mock data when I use a resolvers with @client directive and nested fragments.

Actual outcome:

I get an error when I use this fragment

fragment locationFields on Location {
    formattedAddress
    coordinates {
        ...geoCoordinatesFields
    }
}
query GetWalletScreenInfo {
    me {
        id
        wallets {
            ...walletFields
        }
    }
    duePaymentRequests @client {
        id
        issuer {
            email
            id
            name
            tag
            phone
            addresses {
                id
                location {
                    ...locationFields
                }
              ...

auth.tsx->errorLink->graphQLErrors {"locations": [{"column": 1, "line": 36}], "message": "Fragment \"geoCoordinatesFields\" is never used."}

but it works fine when I use not nested fragments like

fragment geoCoordinatesFields on GeoCoordinates {
    lat
    long
}
query GetWalletScreenInfo {
    me {
        id
        wallets {
            ...walletFields
        }
    }
    duePaymentRequests @client {
        id
        issuer {
            email
            id
            name
            tag
            phone
            addresses {
                id
                location {
                    formattedAddress
                    coordinates {
                        ...geoCoordinatesFields
                    }
                }
               ...

not issues

How to reproduce the issue:

You can use fragments of any nesting level for reproduce this issue

Versions

System:
   OS: macOS 12.4
 Binaries:
   Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
   Yarn: 1.22.17 - /opt/homebrew/bin/yarn
   npm: 8.11.0 - ~/.nvm/versions/node/v14.18.1/bin/npm
 Browsers:
   Chrome: 104.0.5112.79
   Safari: 15.5
 npmPackages:
   @apollo/client: ^3.4.10 => 3.4.10 
   apollo-absinthe-upload-link: ^1.7.0 => 1.7.0 

@AndreyCashia AndreyCashia changed the title Nested fragments doesn't work with @client directive 🐛 Nested fragments doesn't work with @client directive Aug 12, 2022
@AndreyCashia AndreyCashia changed the title 🐛 Nested fragments doesn't work with @client directive 🐛 Nested fragments don't work with @client directive Aug 12, 2022
@dylanwulf
Copy link
Contributor

Hi, just a reminder to please wrap @client in backticks (``) to avoid accidentally tagging the github user client. Thanks!

@AndreyCashia AndreyCashia changed the title 🐛 Nested fragments don't work with @client directive 🐛 Nested fragments don't work with @client directive Aug 13, 2022
@AndreyCashia
Copy link
Author

Maybe someone knows how to solve this issue?

@dylanwulf
Copy link
Contributor

Not sure if this will help with your issue, but if your GraphQL schema has unions or interfaces make sure you have possibleTypes configured correctly: https://www.apollographql.com/docs/react/data/fragments/#defining-possibletypes-manually

@alessbell
Copy link
Contributor

Hi @AndreyCashia 👋 Do you have a runnable reproduction you can share? Thanks!

@alessbell alessbell added the 🏓 awaiting-contributor-response requires input from a contributor label Jan 12, 2023
@github-actions
Copy link
Contributor

We're closing this issue now but feel free to ping the maintainers or open a new issue if you still need support. Thank you!

@github-actions
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
4 participants