Trying to puzzle out a recent post from @jorfermo
I’ve found that uploading a schema that changes the output type of a custom resolver does not work correctly. It appears to actually append the newer type, which then just gets ignored whenever the meta data is transformed into a schema.
Simplest case:
this is an entire schema definition to upload. Start with a function that outputs a Named
type.
type Query {
hello: String @resolver
}
try to change it to a List
type
type Query {
hello: [String] @resolver
}
Change it again to a Non-Null
type. Change the Named
type for good measure.
type Query {
hello: Int! @resolver
}
Expected behavior
UDFs are flexible, so we should expect that our UDFs can change, either through evolution or because we made a mistake.
The GraphQL API just works.
The meta data should only read the last type that was uploaded.
Get(Function("hello"))
{
ref: Ref(Ref("functions"), "hello"),
ts: 1618355754830000,
name: "hello",
data: {
gql: {
ts: Time("2021-04-13T23:15:54.580168Z"),
meta: {
location: "Query",
field: {
name: "hello",
directives: [
{
name: "resolver",
args: {
name: "hello",
paginated: false
}
}
],
type: { // <-- The field we're interested in
NotNull: {
Named: "Int"
}
}
}
}
}
},
body: Query(Lambda([], "hello"))
}
Actual Behavior
All of the schema uploaded work. But the generated schema does not change.
The change to the schema appears to work like FQL Update – it merges the new value in, but does not remove the old ones. here is the unedited response.
Get(Function("hello"))
{
ref: Ref(Ref("functions"), "hello"),
ts: 1618355754830000,
name: "hello",
data: {
gql: {
ts: Time("2021-04-13T23:15:54.580168Z"),
meta: {
location: "Query",
field: {
name: "hello",
directives: [
{
name: "resolver",
args: {
name: "hello",
paginated: false
}
}
],
type: {
Named: "String", // <-- original schema
List: { // <-- update to list
Named: "String"
},
NotNull: { // <-- update to Non Null
Named: "Int"
}
}
}
}
}
},
body: Query(Lambda([], "hello"))
}
Another quick example
Just confirming its not just scalar types effected. It happens any time you change the type from Named
, List
, or Non Null
. Extra surprising if you change the base time and expect that to work.
type Post {
title: String!
}
type Query {
favoriteOf(id: ID!): Post @resolver
}
to this, for example
type Page {
title: String!
}
type Query {
favoriteOf(id: ID!): Page! @resolver
}
the meta-data type will be
type: {
Named: "Post",
NotNull: {
Named: "Page"
}
},