0
votes

I'm using

  • Neo4J 4.2
  • Apollo server
  • GraphQL & @neo4j/graphql (to generate Neo4J types from schema.graphql)
  • Expo React Native + Apollo Client
  • TypeScript

And I wanted to generate TS types for GraphQL queries by following this tutorial.

By default apollo-cli will look in ./src folder, but in React Native I don't have such a folder, it's all in root. So when I tried to change includes config for apollo client like so:

<root>/apollo.config.js

module.exports = {
  client: {
    includes: ['**/*.{ts,tsx}'],
  },
};

Running

> apollo codegen:generate --endpoint=http://localhost:4001/ --target=typescript --tagName=gql

Resulted in:

Error: Error initializing Apollo GraphQL project "Unnamed Project": Error: Error in "Loading queries for Unnamed Project": Error: ️️There are multiple definitions for the `OpName` operation. Please rename or remove all operations with the duplicated name before continuing.
1

1 Answers

0
votes

After many hours, I fixed this issue by using the following config:

module.exports = {
  client: {
    includes: ['graphql/**/*.ts'],
  },
};

My guess is that apollo-cli found some gql tags in all the React Native generated code.

P.S. I tried to use specific keywords so that Google will show this result to people that have the same issue and are stuck.