Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shorthand query syntax breaks types for queries #372

Closed
JohannesHoppe opened this issue Jun 13, 2018 · 3 comments
Closed

shorthand query syntax breaks types for queries #372

JohannesHoppe opened this issue Jun 13, 2018 · 3 comments
Labels
waiting-for-release Fixed/resolved, and waiting for the next stable release

Comments

@JohannesHoppe
Copy link

JohannesHoppe commented Jun 13, 2018

I'm using the graphql-codegen-typescript-template.
Having this

query BookList {
  books {
    title
    description,
    rating
    thumbnails {
      url
    }
  }
}

works fine. I get a namespace BookList with all required types.

export namespace BookList {
  export type Variables = {};

  export type Query = {
    ....
  };
....
}

But using the shorthand syntax without operation name (see here) breaks the code.

export const booksQuery = gql`
{
  books {
    isbn
    title
    description,
    rating
    thumbnails {
      url
    }
  }
}
`;

results in:
(two empty spaces and absolutely nothing else)

export namespace  {
  export type Variables = {
  }
  ...
}

Proposal:
Queries without a name are going to be ignored.

@dotansimha dotansimha added the bug label Jun 14, 2018
@dotansimha
Copy link
Owner

Yeah that's definitely a bug. will fix soon :)

@dotansimha
Copy link
Owner

@JohannesHoppe Just tested and it seems that shorthand syntax works and the document-finder find the document correctly.
The issue here is the fact that your Query does not have a name now.
In the past, we had a names generator for anonymous GraphQL documents, I guess that I need to add it now as well.

JohannesHoppe added a commit to angular-schule/website-articles that referenced this issue Jun 14, 2018
@dotansimha
Copy link
Owner

dotansimha commented Jun 14, 2018

Fixed (and some other changes...) here: #374
Will merge soon after some tests.

@JohannesHoppe

@dotansimha dotansimha added the waiting-for-release Fixed/resolved, and waiting for the next stable release label Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-release Fixed/resolved, and waiting for the next stable release
Projects
None yet
Development

No branches or pull requests

2 participants