title: Apollo client for angular: code generation from graphql files
body: <p>I came to know about <a href="https://graphql-code-generator.com/docs/plugins/typescript-apollo-angular" rel="nofollow noreferrer">angular graphql code generator</a> from <a href="https://www.apollographql.com/docs/angular/basics/services/#code-generation" rel="nofollow noreferrer">here</a>. I am trying to use it in my project to generate the graphql types and <code>Query</code> services for angular.</p>
  
  <p>My codegen.yml file looks like below.</p>
  
  <pre><code>overwrite: true
  schema: "http://localhost:9010/myGraphQL"
  documents: "apps/myGraphQLApp/src/gqls/**/*.graphql"
  generates:
    apps/myGraphQLApp/src/app/generated/graphql.ts:
      plugins:
        - "typescript"
        - "typescript-operations"
        - "typescript-apollo-angular"
  </code></pre>
  
  <p>I have a graphql file <code>apps\myGraphQLApp\src\gqls\myBooks.graphql</code> with following content</p>
  
  <pre><code>query GetMyBooks {
    books{
      id
      name
    }
  }
  </code></pre>
  
  <p>I am running <code>npx graphql-codegen --config codegen.yml</code>, and it fails with following error.</p>
  
  <pre><code>  √ Parse configuration
    &gt; Generate outputs
      &gt; Generate apps/myGraphQLApp/src/app/generated/graphql.ts
        √ Load GraphQL schemas
        √ Load GraphQL documents
        × Generate
          → Query root type must be provided.
  
  
   Found 1 error
  
    × apps/myGraphQLApp/src/app/generated/graphql.ts
      Error: Query root type must be provided.
          at assertValidSchema (....\node_modules\graphql\type\validate.js:71:11)
          ...
  </code></pre>
  
  <p>My graphql server definitely exposes a query root, and I can invoke it with different clients.</p>
  
  <pre><code>schema {
    query: MyGraphQLQueryType
  }
  </code></pre>
  
  <p>I am not sure what I am doing wrong. Any help will be appreciated.</p>