Skip to content
Advertisement

ApolloError: Fragment was used, but not defined

I have this in my complicated app:

JavaScript

Basically, I have an export button which will export a CSV of my GraphQL data. I manually call client.query to fetch the latest data on click of the button, but it throws an error saying it can’t find the used fragment StuffTable. How do I include that fragment in the query?

I am getting this error:

JavaScript

How do I include the Fragment in my manual client.query or whatever I need to do to resolve this error and get it to work?

Is there something like this I can do?

JavaScript

I’m looking at the docs but don’t see anything of help.

Advertisement

Answer

You’ll need to import the fragment into your query code. Instead of this:

JavaScript

You can do this:

JavaScript

That will make sure that the fragment StuffTable is included in your query!

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement