-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Describe the bug
Codegen doesn't know how to handle backtick escaping in template literals.
To Reproduce
Define your schema in a js or ts file, with the help of graphql-tag. And add a field description that uses backtickets to highlight some code in your document browser. (graphql playground for example).
- My GraphQL schema:
import gql from 'graphql-tag';
export default gql`
type Query {
user(id: ID!): User!
}
type User {
id: ID!
"Choose a nice username, so users can \`@mention\` you."
username: String!
email: String!
}
`;Error thrown:
✖ GraphQL request
Syntax Error: Invalid character escape sequence: \`.
GraphQL request (7:42)
6: id: ID!
7: "Choose a nice username, so users can \`@mention\` you."
^
8: username: String!
Sandbox: https://codesandbox.io/s/codegen-backtick-escape-issue-qn1hb
- My
codegen.ymlconfig file:
schema: schema.js
documents: operations.graphql
generates:
types.ts:
plugins:
- typescript
- typescript-operationsExpected behavior
Having User with a generated type like:
export type User = {
__typename?: "User";
id: Scalars["ID"];
/** Choose a nice username, so users can `@mention` you. */
username: Scalars["String"];
email: Scalars["String"];
};
Environment:
- OS: codesandbox
@graphql-codegen/add: 1.3.1@graphql-codegen/cli: 1.3.1@graphql-codegen/typescript: 1.3.1@graphql-codegen/typescript-operations: 1.3.1- NodeJS: v10.16.0
Additional context
In the sanbox posted above, you can change the codegen.yml to use schema.graphql instead of schema.js to see it work. That's the desired outcome, only I need to be able to use .js / .ts files with graphql-tag.
Writing my descriptions like I do in the sandbox, does work, as Apollo parses it and graphql playground displays it. It's only codegen that doesn't compile it.