title: useQuery: data undefined
body: <p>my problem is quite strange. When I call a query in graphiql it works. As soon as I do it in my React app it doesn't. Question marked in code: When I log just dataCategories I get the object. When I try to log dataCategories.allCategories then I get the error &quot;dataCategories undefined&quot;. I absolutely have no clue what is going on here...</p>
  <pre><code>const NEW_TWEET = gql`
      mutation createTweet($title: String!, $content: String!) {
          createTweet(input: { title: $title, content: $content }) {
              _id
              title
              content
              date
          }
      }
  `;
  
  const TWEETS_QUERY = gql` {
      allTweets {
          _id
          title
          content
          date
       }
  }`;
  
  const CATEGORIES_QUERY = gql` {
      allCategories {
          _id   
          label
      }
  }`;
  
  const NewTweet = () =&gt; {
  
      let history = useHistory();
  
      const [title, setTitle] = useState(&quot;&quot;);
      const [content, setContent] = useState(&quot;&quot;);
  
      const [createTweet] = useMutation(NEW_TWEET, {
          update(
              cache,
              {data: {createTweet}}
          ) {
              const {allTweets} = cache.readQuery({ query: TWEETS_QUERY });
              cache.writeQuery({
                  query: TWEETS_QUERY,
                  data: { allTweets: allTweets.concat([createTweet])}
              });
          }
      });
  
      const { loading: loadingCategories, error: errorCategories, data: dataCategories } = useQuery(CATEGORIES_QUERY);
      console.log(dataCategories));
      ////// When I log just dataCategories I get the object. When I try to log dataCategories.allCategories then I get the errer &quot;dataCategories undefined&quot;.
  
      return (
          &lt;div className=&quot;container m-t-20&quot;&gt;
              &lt;h1 className=&quot;page-title&quot;&gt;New Tweet&lt;/h1&gt;
              &lt;div className=&quot;newnote-page m-t-20&quot;&gt;
                  &lt;form onSubmit={e =&gt; {
                                      e.preventDefault();
                                      createTweet({
                                          variables: {
                                              title,
                                              content,
                                              date: Date.now()
                                          }
                                      });
                                      notify.show(&quot;Tweet was created succuessfully.&quot;, &quot;success&quot;)
                                      history.push('/');
                                  }
                  }&gt;
                      &lt;div className=&quot;field&quot;&gt;
                          &lt;label className=&quot;label&quot;&gt;Tweet Title&lt;/label&gt;
                          &lt;div className=&quot;control&quot;&gt;
                              &lt;input name=&quot;title&quot; className=&quot;input&quot; type=&quot;text&quot; placeholder=&quot;Tweet Title&quot; value={title} onChange={e =&gt; setTitle(e.target.value)} /&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div className=&quot;field&quot;&gt;
                          &lt;label className=&quot;label&quot;&gt;Tweet Content&lt;/label&gt;
                          &lt;div className=&quot;control&quot;&gt;
                              &lt;textarea name=&quot;content&quot; className=&quot;textarea&quot; rows=&quot;10&quot; placeholder=&quot;Tweet Content here...&quot; value={content} onChange={e =&gt; setContent(e.target.value)}&gt;&lt;/textarea&gt;
                          &lt;/div&gt;
                     {/*} &lt;Autocomplete
                          multiple
                          id=&quot;tags-outlied&quot;
                          options={dataCategories.allCategories}
                          getOptionLabel={(option) =&gt; option.label}
                          filterSelectedOptions
                          renderInput={(params) =&gt; (
                              &lt;TextField
                                  {...params}
                                  label=&quot;Kategorien&quot;
                                  placeholder=&quot;Kategorien&quot;
                              /&gt;
                          )}
                          /&gt;*/}
                      &lt;div className=&quot;field&quot;&gt;
                          &lt;div className=&quot;control&quot;&gt;
                              &lt;button className=&quot;button is-link&quot;&gt;Submit&lt;/button&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      );
  }
  
  export default NewTweet;
  </code></pre>
  <p>The schema is:</p>
  <pre><code>import { makeExecutableSchema } from &quot;@graphql-tools/schema&quot;;
  import { resolvers } from &quot;./resolvers&quot;;
  
  const typeDefs = `
      type Tweet {
          _id: ID!,
          title: String!,
          date: Date,
          content: String!
      }
      
      scalar Date
  
      type Category {
          _id: ID!,
          label: String!
      }
  
      type Query {
          getTweet(_id: ID!) : Tweet
          allTweets : [Tweet]
          getCategory(Cat: ID!) : Category
          allCategories : [Category]
      }
  
      input TweetInput {
          title: String!,
          content: String!
      }
  
      input CategoryInput {
          label: String!
      }
  
      input TweetUpdateInput {
          title: String,
          content: String
      }
  
      type Mutation {
          createTweet(input: TweetInput) : Tweet
          updateTweet(_id: ID!, input: TweetUpdateInput) : Tweet
          deleteTweet(_id: ID!) : Tweet
          createCategory(input: CategoryInput) : Category
          deleteCategory(_id: ID!) : Category
      }
  `;
  
  const schema = makeExecutableSchema({
      typeDefs,
      resolvers
  });
  
  export default schema;
  </code></pre>
  <p>The resolvers are:</p>
  <pre><code>import Category from './models/category'
  
  export const resolvers = {
      Query : {
          async getTweet(root, { _id }) {
              return await Tweet.findById(_id);
          },
          async allTweets() {
              return await Tweet.find();
          },
          async getCategory(root, {_id}) {
              return await Category.findById(_id);
          },
          async allCategories() {
              return await Category.find();
          }
      },
      Mutation : {
          async createTweet(root, { input }) {
              return await Tweet.create(input);
          },
          async updateTweet(root, { _id, input }) {
              return await Tweet.findOneAndUpdate({_id}, input, {new: true});
          },
          async deleteTweet(root, {_id}) {
              return await Tweet.findOneAndRemove({_id});
          },
          async createCategory(root, { input }) {
              return await Category.create(input);
          },
          async deleteCategory(root, {_id}) {
              return await Category.findOneAndRemove({_id});
          }
      }
  }
  </code></pre>