Search code examples
javascriptecmascript-6apollostack

How to Modify This ES6 Code so as to Insert a Breakpoint?


I'm learning ES6 syntax, as well as the latest Apollo libs. This withData code is adapted from the Githunt-React Apollo demo.

const withData = graphql(GETIMS_QUERY, {
    options: ({ params }) => ({
        variables: {
            "fromID": Meteor.userId(),
            "toID": `${params.toID}`,
        },
    }),
});

params doesn't seem to contain what I expect. I'd like to insert a breakpoint in order to examine the contents of params. But if I add a breakpoint next to options, I find that params is undefined.

I guess I may need to add a breakpoint inside this code block in order to see the contents of params:

const withData = graphql(GETIMS_QUERY, {
    options: ({ params }) => ({
        //IS THERE A WAY TO ADD A BREAKPOINT IN HERE SOMEHOW?
        //MAYBE RETURN `VARIABLES` AS A FUNCTION RESULT?
        variables: {
            "fromID": Meteor.userId(),
            "toID": `${params.toID}`,
        },
    }),
});

Is there a way to do that?

Thanks in advance to all for any info.


Solution

  • You can call console.log (and you can add a breakpoint on that line) and return the object explicitly:

    const withData = graphql(GETIMS_QUERY, {
        options: ({ params }) => {
            console.log(params);
    
            return {
              variables: {
                "fromID": Meteor.userId(),
                "toID": `${params.toID}`,
              },
            };
        },
    });