apollographql / apollographql/apollo-tooling
Client Mutation Not Found for codegen
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
**Intended outcome:**
I have a the following schema defined.
```
type Entity {
...
id: ID!
name: String
org: Org
...
}
input EntityInput {
name: String!
orgId: ID!
}
type Mutation {
...
CreateEntity(input: EntityInput!): Entity
...
}
```
I'm trying to create a client-side mutation and would like to get the types generated for the following mutation and returned object code.
```
mutation ClientCreateEntity(input: EntityInput!) {
CreateEntity(input: $input) {
id
name
}
}
```
I expect codegen to create the appropriate typescript models.
However, If I change the client mutation to the following:
```
mutation ClientCreateEntity {
CreateEntity(input: {name: "", orgId: ""}) {
id
name
}
}
```
It will generate typescript models.
I'm using the following cmd:
`apollo client:codegen --target typescript --config apollo.config.js --outputFlat src/specs/gen`
with the following config
```
module.exports = {
client: {
service: {
name: 'local',
url: 'http://localhost:3000/graphql',
includes: ['src/**/*.graphql'],
},
}
}
```
**Actual outcome:**
```
✔ Loading Apollo Project
✖ Generating query files with 'typescript' target
→ No operations or fragments found to generate code for.
```
**How to reproduce the issue:**
TBD. If needed I'll provide a repo repo.
**Versions**
I've tested the failing case above with the following version of the apollo package:
2.1 - 2.12, 2.19, 2.25 and 2.27.
Contributor guide
Research direction
Start with the Apollo CLI command and apollo.config.js, then inspect the operation matching files under src/**/*.graphql. Reproduce the variable-based mutation failure and compare it with the inline-input version; done means the former is discovered and TypeScript models are generated without the “No operations or fragments” error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100