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;








3















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 needed when 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(),
);









share|improve this question
























  • 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 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

















3















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 needed when 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(),
);









share|improve this question
























  • 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 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













3












3








3








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 needed when 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(),
);









share|improve this question
















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 needed when 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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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 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

















  • 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 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
















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












1 Answer
1






active

oldest

votes


















0














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,
);





share|improve this answer























    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
    );



    );













    draft saved

    draft discarded


















    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









    0














    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,
    );





    share|improve this answer



























      0














      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,
      );





      share|improve this answer

























        0












        0








        0







        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,
        );





        share|improve this answer













        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,
        );






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 1 at 7:31









        brandNewbrandNew

        1,808725




        1,808725





























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현