Abstract type Node must resolve to an Object type at runtime for field Root.node with value \"\",received \"null\"."
<p>I am implementing a search feature with react and relay.
Below is my schema.js</p>

<pre><code>var { nodeInterface, nodeField } = nodeDefinitions(
  (globalId) =&gt; {
    var { type, id } = fromGlobalId(globalId);
    if (type === 'User') {
      return getUser(id);
    }else if (type === 'Post') {
      return getPost(id);
    }else if (type === 'Setting') {
      return getSetting(id);
    }
    return null;
  },
  (obj) =&gt; {
    if (obj instanceof User) {
      return userType;
    }else if (obj instanceof Post) {
      return postType;
    }else if (obj instanceof Setting) {
      return settingType;
    }
    return null;
  }
);

var postType = new GraphQLObjectType({
  name: 'Post',
  fields: {
    _id: {
      type: new GraphQLNonNull(GraphQLID)
    },
    createdAt: {
      type: GraphQLString
    },
    id: globalIdField('Post'),
    title: {
      type: GraphQLString
    },
    color: {
      type: GraphQLString
    },
    userId: globalIdField('User'),
    username: {
      type: GraphQLString,
      resolve: (post) =&gt; getUserById(post.userId),
    },
    content: {
      type: GraphQLString
    },
    images: {
      type: postImageType,
      description: "Post's main image links"
    }
  },
  interfaces: [nodeInterface]
});
const {
  connectionType: postConnection,
} = connectionDefinitions({name: 'Post', nodeType: postType});

var settingType = new GraphQLObjectType({
  name: 'Setting',
  fields: {
    _id: {
      type: new GraphQLNonNull(GraphQLID)
    },
    id: globalIdField('Setting'),
    amount: {
      type: GraphQLString
    },
    all_posts: {
      type: postConnection,
      args: {
       ...connectionArgs,
        query: {type: GraphQLString}
      },
      resolve: (rootValue, args) =&gt; connectionFromPromisedArray(
        getAllPosts(rootValue, args),
        args
      ),
    },
  },
  interfaces: [nodeInterface]
});

var Root = new GraphQLObjectType({
  name: 'Root',
  fields: () =&gt; ({
    node: nodeField,
    setting: {
      type: settingType,
      args: {
         ...connectionArgs,
          currency: {type: GraphQLString}
        },
      resolve: (rootValue, args) =&gt; {
       return getSetting(args.currency).then(function(data){
        return data[0];
       }).then(null,function(err){
        return err;
       });
      }
    },
  })
});
</code></pre>

<p>Below is my database.js</p>

<pre><code>export function getAllPosts(params,args) {
  let findTitle = {};
  let findContent = {};
  if (args.query) {
    findTitle.title = new RegExp(args.query, 'i');
    findContent.content = new RegExp(args.query, 'i');
  }
  console.log("getAllPosts",args)
  return new Promise((resolve, reject) =&gt; {
      Post.find({$or: [findTitle,findContent]}).sort({createdAt: 'descending'}).exec({}, function(err, posts) {
        if (err) {
          resolve({})
        } else {
          resolve(posts)
        }
      });
  })
}
</code></pre>

<p>Now I want to fetch all posts by $query variable
So in view I wrote like this</p>

<pre><code>import React, { Component } from 'react';
import Relay from 'react-relay';

class BlogList extends Component {
  constructor(props) {
    super(props);
    this.state = {
      query: '',
    };
    this.handleSubmit = this.handleSubmit.bind(this);
  }

  handleSubmit(){
    this.props.relay.setVariables({query: this.state.query});
  }
  render() {
    return (

        &lt;div className="input-group col-md-12"&gt;
            &lt;input type="text" onChange={this.handleChange.bind(this,"query")} value={this.state.query} name="query" placeholder="Enter Title or content"/&gt;&lt;br/&gt;

            &lt;span className="input-group-btn"&gt;
                &lt;button type="button" onClick={this.handleSubmit} className="btn btn-info btn-lg"&gt;
                    &lt;i className="glyphicon glyphicon-search"&gt;&lt;/i&gt;
                &lt;/button&gt;
            &lt;/span&gt;
        &lt;/div&gt;
    )
  }
};

export default Relay.createContainer(BlogList, {
  initialVariables: {
    query: ''
  },
  fragments: {
    viewer: () =&gt; Relay.QL`
      fragment on Setting {
        id,
        all_posts(first: 10000000,query: $query) {
          edges {
            node {
              id,
              _id,
              title,
              content,
              createdAt,
              username,
              color,
              images{
                full
              }
            }
          }
        }
      }
    `,
  },
});
</code></pre>

<p>And in routes I have</p>

<pre><code>const SettingQueries = {
 viewer: () =&gt; Relay.QL`query{
  setting(currency: "USD")
 }`,
}
export default [{
  path: '/',
  component: App,
  queries: UserQueries,PostQueries,SettingQueries,
  indexRoute: {
    component: IndexBody,
  },
  childRoutes: [ 
  ,{
    path: 'settings',
    component: Setting,
    queries: SettingQueries,
  }]
}]
</code></pre>

<p>Things are working on /graphql as
<a href="https://i.stack.imgur.com/iim3Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iim3Y.png" alt="Graphql UI"></a></p>

<p>but when I search from website it generates error in response </p>

<pre><code>{
  "data": {
    "node": null
  },
  "errors": [
    {
      "message": "Abstract type Node must resolve to an Object type at runtime for field Root.node with value \"\",received \"null\".",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ]
    }
  ]
}
</code></pre>

<p>as my web-browser is sending requests as below
<a href="https://i.stack.imgur.com/E4EBN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E4EBN.png" alt="enter image description here"></a></p>

<p>Please suggest me what am I missing?
Also If I need to add some additional information please let me know.</p>