Skip to content

Some kind of conflict with graphql-js 14.0.0 #577

@Slessi

Description

@Slessi

Minimal repro here: https://github.com/Slessi/apollo-minimal-repro

Using apollo cli (tried 1.7.1 and 1.9.1) with graphql-js 14.0.0 doesn't seem to work for generating queries.

Generating schema still ok.

OK:

apollo schema:download --endpoint=http://localhost:4000/graphql schema.json

 ✔ Loading Apollo config
 ✔ Fetching current schema
 ✔ Saving schema to schema.json

NOT OK:

Note: I am not actually trying to query __typename in my .graphql

apollo codegen:generate --queries=src/**/*.graphql --schema=schema.json --target=typescript --addTypename --customScalarsPrefix=\"GQL\" --outputFlat src/components/GraphQL/types.ts

 ✔ Loading Apollo config
 ✔ Scanning for GraphQL queries (48 found)
 ✖ Generating query files with 'typescript' target
   → Cannot query field "__typename" on type "User"
GraphQLError: Cannot query field "__typename" on type "User"
    at Compiler.compileSelection (~/<proj>/node_modules/apollo-codegen-core/lib/compiler/index.js:120:27)
    at selections.selectionSetNode.selections.map.selectionNode (~/<proj>/node_modules/apollo-codegen-core/lib/compiler/index.js:106:76)
    at Array.map (<anonymous>)
    at Compiler.compileSelectionSet (~/<proj>/node_modules/apollo-codegen-core/lib/compiler/index.js:106:18)
    at Compiler.compileFragment (~/<proj>/node_modules/apollo-codegen-core/lib/compiler/index.js:99:32)
    at Object.compileToIR (~/<proj>/node_modules/apollo-codegen-core/lib/compiler/index.js:19:43)
    at Object.generate [as default] (~/<proj>/node_modules/apollo/lib/generate.js:74:36)
    at Task.task (~/<proj>/node_modules/apollo/lib/commands/codegen/generate.js:98:64)
    at Promise.resolve.then.then.skipped (~/<proj>/node_modules/listr/lib/task.js:167:30)
    at <anonymous>

The problem begins when my project requires 14.0.0.

I can "fix" the problem by deleting node_modules/apollo/node_modules/graphql/ as the library then uses node_modules/graphql, which is 14.0.0, so maybe just needs a version bump? Don't understand why there would be a problem when both versions exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🌹 has-reproduction❤ Has a reproduction in a codesandbox or single minimal repository

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions