-
Notifications
You must be signed in to change notification settings - Fork 731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not generating code for subtypes only used as input to mutations? #2550
Comments
Same issue here. Generated code is not compiling due to it referencing objects that are not generated. |
Thanks for this bug report @vrutberg - we'll get a fix in ASAP and out in the coming |
I'm very confused here. I cannot get this to reproduce right now. I've written this test, which is passing. func testCompile_inputObject_referencingEnumType_referencedTypesContainsInputObjectAndEnum() throws {
// given
schemaSDL = """
type Mutation {
mutateCar(input: ReportCarProblemInput!): Car!
}
enum CarProblem {
NO_FUEL
}
input ReportCarProblemInput {
carId: UUID!
problem: CarProblem!
}
scalar UUID
interface Car {
name: String!
}
"""
document = """
mutation Test($input: ReportCarProblemInput!) {
mutateCar(input: $input) {
name
}
}
"""
// when
let compilationResult = try compileFrontend()
let inputObject = compilationResult.referencedTypes
.first { $0.name == "ReportCarProblemInput"} as? GraphQLInputObjectType
let enumType = compilationResult.referencedTypes
.first { $0.name == "CarProblem"} as? GraphQLEnumType
// then
expect(inputObject).toNot(beNil())
expect(enumType).toNot(beNil())
} @vrutberg Does anything look different in the schema and mutation defined here from what you have in your graphql files? Enough people are having this issue that I know it's a me problem right now haha. |
I have run the entire code gen engine with the schema and operation above and I am getting a generated enum for If someone who is experiencing this issue can create an example project that reproduces this to send to me, I would be really greatful! |
I've tried your test @AnthonyMDev and it does indeed work, but if I create a GraphQL server with that schema, then introspect it and use the resulting JSON in the same test, it fails to find the enum type. Maybe the issue is in parsing the JSON schemas. Here's the schema I'm using: https://gist.github.com/tngranados/8eee8b92dac430eacfdddf8f04fec721 I got from introspecting this node server: var express = require('express');
const { graphqlHTTP } = require('express-graphql');
var { buildSchema } = require('graphql');
// GraphQL schema
var schema = buildSchema(`
type Query {
message: String
}
type Mutation {
mutateCar(input: ReportCarProblemInput!): Car!
}
enum CarProblem {
NO_FUEL
}
input ReportCarProblemInput {
carId: UUID!
problem: CarProblem!
}
scalar UUID
interface Car {
name: String!
}
`);
// Root resolver
var root = {
message: () => 'Hello World!'
};
// Create an express server and a GraphQL endpoint
var app = express();
app.use('/graphql', graphqlHTTP({
schema: schema,
rootValue: root,
graphiql: true
}));
app.listen(4000, () => console.log('Express GraphQL Server Now Running On localhost:4000/graphql')); |
I think @tngranados is on to something, we are also using a JSON based schema derived from an introspection query. |
Thanks for the info! I'll look into this now! |
I was able to reproduce using JSON schema and have the fix now. Will be putting up a PR shortly! Thanks everyone! |
Okay, the fix is now in |
Bug report
We have been attempting to move from apollo-ios 0.53.0 to 1.0.0 and have encountered a problem where code generation doesn't seem to generate code for subtypes that are only used as input. This worked for us using version 0.53.0.
Versions
Please fill in the versions you're currently using:
apollo-ios
SDK version: 1.0.0Further details
Basically we have a mutation accepting a custom type as input. The type roughly looks like this:
This is then used in a mutation:
When this code is generated, there's a compiler error where the generated code for
ReportCarProblemInput
references theCarProblem
enum, because the code for it hasn't been generated.If I manually add a queryable field of the
CarProblem
type, and a query for it, and then generate code, the generated code forReportCarProblemInput
works as expected.The text was updated successfully, but these errors were encountered: