What is this compilation error about? Duplicate identifier 'gql'. export default gql;
I just upgraded from Angular 9 to Angular 10. I did a clean install of all dependences and then copied my code into the Angular 10 directory. Of course when compiling there were issues but this is the only one I couldn't fix. My GraphQL code including fragments worked fine in Angular 9 and before so I don't think it is my code. I have graphql-tag in apollo-angular-boost 1.9.0 and Apollo-client 2.6.10.
Where do I look to solve this? The error messages never mention my code and when I check it my code seems to follow your docs guidance.
And now for the exciting part in Terminal :-)
ERROR in node_modules/apollo-angular-boost/node_modules/graphql-tag/index.d.ts:14:18 - error TS2300: Duplicate identifier 'gql'.
export default gql;
node_modules/graphql-tag/index.d.ts:14:18
export default gql;
'gql' was also declared here.
The above is printed out again a second time.
My frags example. While I have multiple frags on a page they all have different names.
import gql from 'graphql-tag';
export const membersTableFrag = gql`
fragment membersTableFrag on Member {
member_id
first_name
last_name
}
`;
Update:
I've been trying to solve this issue and deleted some unrelated links that I no longer need. That seems to free up the compiler for this message.
unique-name.service.ts depends on 'graphql-tag'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
When I put this code in the angular.json build options the message goes away. It doesn't solve the original problem but it seems that graphic-tag should replace the CommonJS dependency. It significantly increases the build size.
"allowedCommonJsDependencies": [
"lodash",
"CommonJS"
],
Hello @jmpreston , probably there are some left gql import from graphql-tag. Be sure to have replaced all import { gql } from 'graphql-tag'; to import { gql } from 'apollo-angular';
Hello @jmpreston , probably there are some left
gqlimport fromgraphql-tag. Be sure to have replaced allimport { gql } from 'graphql-tag';toimport { gql } from 'apollo-angular';
Not the issue. My importing was the old way of doing it at the date of my posting.