2

I'm relatively new to Relay, so this may be an easy mistake I've made but I've been looking for some time already and I haven't found any information about the problem I'm having.

This is the error that I get from my application:

Uncaught Error: Invariant Violation: GraphQLFragmentPointer: Value for the argument to story on query Route should be a string, but it was set to 10. Check that the value is a string.

The problem is I actually want it to be 10 and don't want it to be string. Have I configured something incorrectly?

This is my GraphQL Schema:

var queryType = new GraphQLObjectType({
    name: 'Query',
    fields: () => ({
        node: nodeField,
        story: {
            type: storyType,
            args: {
                storyID: {
                    description: 'Story ID',
                    type: GraphQLInt
                }
            },
            resolve: (root, {storyID}) => {
                if (storyID) {
                    return Story.get(storyID)
                } else {
                    return Story.get(10)
                }
            }
        },
    }),
});

This is the relay route I've defined:

export default class extends Relay.Route {
  static queries = {
    story: () => Relay.QL`
      query {
        story(storyID: $storyID)
      }
    `,
  };

  static paramDefinitions = {
    storyID: {
        required: false
    },
  };

  static routeName = 'StoryRoute';
};

And this is how I instantiate it:

let route = new Route({storyID: 10})

1 Answer 1

2

Ok, it looks like I've figured it out finally.

It appears that root fields are severely limited and can currently only have no parameters, a single string parameter or a multiple string parameters, connected straight with IDs of objects fetched.

Look for more information here: https://github.com/facebook/relay/issues/112 and here: https://github.com/facebook/relay/issues/94

Sign up to request clarification or add additional context in comments.

1 Comment

@ravibagul91 I'm curious in what sense you found this suggestion was intended to address the author of the post. Thanks for reviewing it in any case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.