```query Project($id: ID!) { project(projectId...
# apollo-kotlin
n
Copy code
query Project($id: ID!) {
    project(projectId: $id) {
        id
        name
    }
}
And I’m calling it with the following:
Copy code
val project = apollo.query(ProjectQuery(projectId)).execute()
What would cause this issue in the screenshot where it says I’m missing a field and some other errors?
m
I'd say you have a disconnect between your server schema and your client schema?
Try to update the schema in the client?
n
I’ve updated it several times 😕, and full clean/rebuilds
m
This is unexpected...
Try editing your schema manually to see if it passes?
n
ok
m
(if you have a json schema, convert it to SDL first with
./gradlew convertApolloSchema --to --from
)
n
its
graphqls
, thats what we want right?
m
Yup
n
i wanna change this block?
Copy code
type Project {
  id: ID!

  name: String!

  annotations(filter: AnnotationFilter): [Annotation!]!

  annotationsCount: Int!
}
m
More the
Query
type
n
it’s
project(projectId: ID!): Project
projectId
id
?
👍 1
m
Change it to
project(id: ID!): Project
n
hmm
oh a rebuild fixed it
m
👍
n
is it possible that the server is giving me a wrong introspection?
m
EVERYTHING is possible 😛
😂 1
n
haha ok 😄
m
That'd be a first for me though but I guess it's technically possible 🙃
What's your server?
n
🤷‍♀️
😂 1
its written in ruby, that’s all i know 😕
m
Asking because some of them might cache the introspection or something like this
n
i’ll reach out and i’ll let you know what i find
thanks again for your quick help
m
Did it work with the manual patching?
n
yeah
m
👍
Yep, most likely sometihng wrong in the server then
👍 1
n
my team is pushing back saying that it is indeed using a
projectId
instead of
id
. they think I might be hitting the wrong endpoint?
here’s how i have it configured:
Copy code
apollo {
    service("[redacted]") {
        srcDir("src/main/graphql/[redacted]")
        generateOptionalOperationVariables.set(false)
        generateApolloMetadata.set(true)
        generateKotlinModels.set(true)
        packageName.set("com.[redacted].apollo")
        // this will create a download[redacted]ApolloSchemaFromIntrospection task
        introspection {
            endpointUrl.set("[redacted]")
            schemaFile.set(file("src/main/graphql/[redacted]/schema.graphqls"))
        }
    }
    service("SmartTrack") {
        srcDir("src/main/graphql/smarttrack")
        generateOptionalOperationVariables.set(false)
        generateApolloMetadata.set(true)
        generateKotlinModels.set(true)
        packageName.set("com.smarttrack.apollo")
        mapScalar("DateTimeUtc", "java.util.Date", "com.apollographql.apollo3.adapter.DateAdapter")
        // this will create a downloadSmartTrackApolloSchemaFromIntrospection task
        introspection {
            headers.set("X-Admin-Token": "[redacted]")
            endpointUrl.set("[redacted]")
            schemaFile.set(file("src/main/graphql/smarttrack/schema.graphqls"))
        }
    }
}
m
The endpoint is used in you runtime code
Well actually there are 2 endpoints
It
projectId
is correct and you get introspection correctly then it means your runtime code is maybe hitting a different endpoint?
n
i verified that it is indeed hitting the wrong endpoint using the app inspection tool
👍 1
🤦‍♂️
i thought i could use the same client
🙃 1
i thought there was magic under the hood that would automatically switch based on what schema was used
thanks again! ❤️
m
Sure thing!
We explored quickly generating code to embed the endpoint in the client but that'd mean you'd have to call different clients
Endpoint1ApolloClient
for an example and it adds some coupling between codegen and the runtime so we decided not to.
It could be helpful at some point for pre-configuring custom scalars too. But it definitely adds some complexity