readFragment causing IntrospectionFragmentMatcher error although not using interface or unions Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Fragment composition with Apollo client: convention and boilerplateGraphql react-apollo IntrospectionFragmentMatcher issuesComponent `props.data` Doesn't Reload After Apollo Refetch()Apollo Client - [BatchHttpLink]: Error writing result to store for queryUsing writeFragment to Update a Field Belonging to an Object?Using ApolloClient with node.js. “fetch is not found globally and no fetcher passed”GraphQLError when sending mutationApollo graphql queries with type condition on nested fieldsGraphql react-apollo IntrospectionFragmentMatcher
Why should I vote and accept answers?
When a candle burns, why does the top of wick glow if bottom of flame is hottest?
Is it a good idea to use CNN to classify 1D signal?
Do any jurisdictions seriously consider reclassifying social media websites as publishers?
What order were files/directories outputted in dir?
What are the diatonic extended chords of C major?
How does the math work when buying airline miles?
Is it possible for SQL statements to execute concurrently within a single session in SQL Server?
How can I reduce the gap between left and right of cdot with a macro?
Time to Settle Down!
What is the meaning of 'breadth' in breadth first search?
Why do we bend a book to keep it straight?
Find 108 by using 3,4,6
ArcGIS Pro Python arcpy.CreatePersonalGDB_management
Can the Great Weapon Master feat's damage bonus and accuracy penalty apply to attacks from the Spiritual Weapon spell?
Converted a Scalar function to a TVF function for parallel execution-Still running in Serial mode
Morning, Afternoon, Night Kanji
What is the appropriate index architecture when forced to implement IsDeleted (soft deletes)?
Trademark violation for app?
Disembodied hand growing fangs
How much damage would a cupful of neutron star matter do to the Earth?
Using audio cues to encourage good posture
What is "gratricide"?
If Windows 7 doesn't support WSL, then what does Linux subsystem option mean?
readFragment causing IntrospectionFragmentMatcher error although not using interface or unions
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Fragment composition with Apollo client: convention and boilerplateGraphql react-apollo IntrospectionFragmentMatcher issuesComponent `props.data` Doesn't Reload After Apollo Refetch()Apollo Client - [BatchHttpLink]: Error writing result to store for queryUsing writeFragment to Update a Field Belonging to an Object?Using ApolloClient with node.js. “fetch is not found globally and no fetcher passed”GraphQLError when sending mutationApollo graphql queries with type condition on nested fieldsGraphql react-apollo IntrospectionFragmentMatcher
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am getting the following error when attempting to fetch a query fragment:
"You are using the simple (heuristic) fragment matcher, but your queries contain union or interface types. Apollo Client will not be able to accurately map fragments. To make this error go away, use the
IntrospectionFragmentMatcher
as described in the docs: https://www.apollographql.com/docs/react/recipes/fragment-matching.html"
This is the call that triggers the error.
const sourceData = cache.readFragment(
id: `$typename:$idToAdd`,
fragment: gql`
$sourceFragment
`,
);
where sourceFragment is
fragment series on PriceSeries
id
title
description
commodity
region
location
isDiscontinued
order
Apollo seems to be classing the return value of the fragment as a union or interface. I don't think adding the IntrospectionFragmentMatcher should be necessary as we have no need of unions or interfaces, although maybe I'm wrong. Adding __typename
to the fragment didn't help.
- How do I remove this error (I may just be missing some gql syntax for typing?)
- Does using fragments mean we should set up the
IntrospectionFragmentMatcher
regardless.. (the docs say it should only be neededwhen using fragments on interfaces or unions
which we are not) - Is the error a bug, should I just be hiding the error (it does work as is if you ignore it)
Update
ApolloClient is created as follows
client = new ApolloClient(
link: createLink('MY_URL', Apollo.fetch),
cache: new InMemoryCache(),
);
javascript reactjs apollo react-apollo apollo-client
|
show 1 more comment
I am getting the following error when attempting to fetch a query fragment:
"You are using the simple (heuristic) fragment matcher, but your queries contain union or interface types. Apollo Client will not be able to accurately map fragments. To make this error go away, use the
IntrospectionFragmentMatcher
as described in the docs: https://www.apollographql.com/docs/react/recipes/fragment-matching.html"
This is the call that triggers the error.
const sourceData = cache.readFragment(
id: `$typename:$idToAdd`,
fragment: gql`
$sourceFragment
`,
);
where sourceFragment is
fragment series on PriceSeries
id
title
description
commodity
region
location
isDiscontinued
order
Apollo seems to be classing the return value of the fragment as a union or interface. I don't think adding the IntrospectionFragmentMatcher should be necessary as we have no need of unions or interfaces, although maybe I'm wrong. Adding __typename
to the fragment didn't help.
- How do I remove this error (I may just be missing some gql syntax for typing?)
- Does using fragments mean we should set up the
IntrospectionFragmentMatcher
regardless.. (the docs say it should only be neededwhen using fragments on interfaces or unions
which we are not) - Is the error a bug, should I just be hiding the error (it does work as is if you ignore it)
Update
ApolloClient is created as follows
client = new ApolloClient(
link: createLink('MY_URL', Apollo.fetch),
cache: new InMemoryCache(),
);
javascript reactjs apollo react-apollo apollo-client
Can you please share the code of creatingInMemoryCache
instance?
– User97
Mar 22 at 10:39
@User97 I've added the code above, its currently got no custom configuration
– Tom
Mar 22 at 10:52
Okay, I don't see any reason for it to throw error in that case as long as$typename
is passed correctly.
– User97
Mar 22 at 10:56
Are you writing directly to cache in your code usingwriteQuery
,writeFragment
orwriteData
? If so, are you omitting writing the__typename
when you do so?
– Daniel Rearden
Mar 22 at 11:59
The error is being thrown when calling `readFragment' so before any write calls. I've tried removing them all and still get the same message
– Tom
Mar 22 at 12:14
|
show 1 more comment
I am getting the following error when attempting to fetch a query fragment:
"You are using the simple (heuristic) fragment matcher, but your queries contain union or interface types. Apollo Client will not be able to accurately map fragments. To make this error go away, use the
IntrospectionFragmentMatcher
as described in the docs: https://www.apollographql.com/docs/react/recipes/fragment-matching.html"
This is the call that triggers the error.
const sourceData = cache.readFragment(
id: `$typename:$idToAdd`,
fragment: gql`
$sourceFragment
`,
);
where sourceFragment is
fragment series on PriceSeries
id
title
description
commodity
region
location
isDiscontinued
order
Apollo seems to be classing the return value of the fragment as a union or interface. I don't think adding the IntrospectionFragmentMatcher should be necessary as we have no need of unions or interfaces, although maybe I'm wrong. Adding __typename
to the fragment didn't help.
- How do I remove this error (I may just be missing some gql syntax for typing?)
- Does using fragments mean we should set up the
IntrospectionFragmentMatcher
regardless.. (the docs say it should only be neededwhen using fragments on interfaces or unions
which we are not) - Is the error a bug, should I just be hiding the error (it does work as is if you ignore it)
Update
ApolloClient is created as follows
client = new ApolloClient(
link: createLink('MY_URL', Apollo.fetch),
cache: new InMemoryCache(),
);
javascript reactjs apollo react-apollo apollo-client
I am getting the following error when attempting to fetch a query fragment:
"You are using the simple (heuristic) fragment matcher, but your queries contain union or interface types. Apollo Client will not be able to accurately map fragments. To make this error go away, use the
IntrospectionFragmentMatcher
as described in the docs: https://www.apollographql.com/docs/react/recipes/fragment-matching.html"
This is the call that triggers the error.
const sourceData = cache.readFragment(
id: `$typename:$idToAdd`,
fragment: gql`
$sourceFragment
`,
);
where sourceFragment is
fragment series on PriceSeries
id
title
description
commodity
region
location
isDiscontinued
order
Apollo seems to be classing the return value of the fragment as a union or interface. I don't think adding the IntrospectionFragmentMatcher should be necessary as we have no need of unions or interfaces, although maybe I'm wrong. Adding __typename
to the fragment didn't help.
- How do I remove this error (I may just be missing some gql syntax for typing?)
- Does using fragments mean we should set up the
IntrospectionFragmentMatcher
regardless.. (the docs say it should only be neededwhen using fragments on interfaces or unions
which we are not) - Is the error a bug, should I just be hiding the error (it does work as is if you ignore it)
Update
ApolloClient is created as follows
client = new ApolloClient(
link: createLink('MY_URL', Apollo.fetch),
cache: new InMemoryCache(),
);
javascript reactjs apollo react-apollo apollo-client
javascript reactjs apollo react-apollo apollo-client
edited Mar 25 at 8:49
Tom
asked Mar 22 at 10:33
TomTom
8,976762103
8,976762103
Can you please share the code of creatingInMemoryCache
instance?
– User97
Mar 22 at 10:39
@User97 I've added the code above, its currently got no custom configuration
– Tom
Mar 22 at 10:52
Okay, I don't see any reason for it to throw error in that case as long as$typename
is passed correctly.
– User97
Mar 22 at 10:56
Are you writing directly to cache in your code usingwriteQuery
,writeFragment
orwriteData
? If so, are you omitting writing the__typename
when you do so?
– Daniel Rearden
Mar 22 at 11:59
The error is being thrown when calling `readFragment' so before any write calls. I've tried removing them all and still get the same message
– Tom
Mar 22 at 12:14
|
show 1 more comment
Can you please share the code of creatingInMemoryCache
instance?
– User97
Mar 22 at 10:39
@User97 I've added the code above, its currently got no custom configuration
– Tom
Mar 22 at 10:52
Okay, I don't see any reason for it to throw error in that case as long as$typename
is passed correctly.
– User97
Mar 22 at 10:56
Are you writing directly to cache in your code usingwriteQuery
,writeFragment
orwriteData
? If so, are you omitting writing the__typename
when you do so?
– Daniel Rearden
Mar 22 at 11:59
The error is being thrown when calling `readFragment' so before any write calls. I've tried removing them all and still get the same message
– Tom
Mar 22 at 12:14
Can you please share the code of creating
InMemoryCache
instance?– User97
Mar 22 at 10:39
Can you please share the code of creating
InMemoryCache
instance?– User97
Mar 22 at 10:39
@User97 I've added the code above, its currently got no custom configuration
– Tom
Mar 22 at 10:52
@User97 I've added the code above, its currently got no custom configuration
– Tom
Mar 22 at 10:52
Okay, I don't see any reason for it to throw error in that case as long as
$typename
is passed correctly.– User97
Mar 22 at 10:56
Okay, I don't see any reason for it to throw error in that case as long as
$typename
is passed correctly.– User97
Mar 22 at 10:56
Are you writing directly to cache in your code using
writeQuery
, writeFragment
or writeData
? If so, are you omitting writing the __typename
when you do so?– Daniel Rearden
Mar 22 at 11:59
Are you writing directly to cache in your code using
writeQuery
, writeFragment
or writeData
? If so, are you omitting writing the __typename
when you do so?– Daniel Rearden
Mar 22 at 11:59
The error is being thrown when calling `readFragment' so before any write calls. I've tried removing them all and still get the same message
– Tom
Mar 22 at 12:14
The error is being thrown when calling `readFragment' so before any write calls. I've tried removing them all and still get the same message
– Tom
Mar 22 at 12:14
|
show 1 more comment
1 Answer
1
active
oldest
votes
You need to create the apollo cache and setup normalization features with dataIdFromObject
.
import InMemoryCache, IntrospectionFragmentMatcher from 'apollo-cache-inmemory';
const fragmentMatcher = new IntrospectionFragmentMatcher(
// Here you may want to pass your introspection query result data,
);
const cache = new InMemoryCache(
dataIdFromObject: o => o.id,
fragmentMatcher,
);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55297699%2freadfragment-causing-introspectionfragmentmatcher-error-although-not-using-inter%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to create the apollo cache and setup normalization features with dataIdFromObject
.
import InMemoryCache, IntrospectionFragmentMatcher from 'apollo-cache-inmemory';
const fragmentMatcher = new IntrospectionFragmentMatcher(
// Here you may want to pass your introspection query result data,
);
const cache = new InMemoryCache(
dataIdFromObject: o => o.id,
fragmentMatcher,
);
add a comment |
You need to create the apollo cache and setup normalization features with dataIdFromObject
.
import InMemoryCache, IntrospectionFragmentMatcher from 'apollo-cache-inmemory';
const fragmentMatcher = new IntrospectionFragmentMatcher(
// Here you may want to pass your introspection query result data,
);
const cache = new InMemoryCache(
dataIdFromObject: o => o.id,
fragmentMatcher,
);
add a comment |
You need to create the apollo cache and setup normalization features with dataIdFromObject
.
import InMemoryCache, IntrospectionFragmentMatcher from 'apollo-cache-inmemory';
const fragmentMatcher = new IntrospectionFragmentMatcher(
// Here you may want to pass your introspection query result data,
);
const cache = new InMemoryCache(
dataIdFromObject: o => o.id,
fragmentMatcher,
);
You need to create the apollo cache and setup normalization features with dataIdFromObject
.
import InMemoryCache, IntrospectionFragmentMatcher from 'apollo-cache-inmemory';
const fragmentMatcher = new IntrospectionFragmentMatcher(
// Here you may want to pass your introspection query result data,
);
const cache = new InMemoryCache(
dataIdFromObject: o => o.id,
fragmentMatcher,
);
answered Apr 1 at 7:31
brandNewbrandNew
1,808725
1,808725
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55297699%2freadfragment-causing-introspectionfragmentmatcher-error-although-not-using-inter%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you please share the code of creating
InMemoryCache
instance?– User97
Mar 22 at 10:39
@User97 I've added the code above, its currently got no custom configuration
– Tom
Mar 22 at 10:52
Okay, I don't see any reason for it to throw error in that case as long as
$typename
is passed correctly.– User97
Mar 22 at 10:56
Are you writing directly to cache in your code using
writeQuery
,writeFragment
orwriteData
? If so, are you omitting writing the__typename
when you do so?– Daniel Rearden
Mar 22 at 11:59
The error is being thrown when calling `readFragment' so before any write calls. I've tried removing them all and still get the same message
– Tom
Mar 22 at 12:14