So, in my schema I used to have a type “Role”, now...
# prisma-whats-new
v
So, in my schema I used to have a type “Role”, now I’ve replaced it with an enum with the same name, but I get this when I deploy
Copy code
No field with id ‘cj9r95arr00220149vgvgme4d’
a
Is the former Type still referenced in your permissions/functions?
v
You’re the man. Yes.
👍🏻 1
Mhm, it still complains… maybe some other reference… not sure
Sorry to bother you still, @agartha — There were indeed references in the graphcool.yml — got rid of them all, but it’s not complaining with this
Copy code
Global
    ✖ Could not create serverless function for 'loggedInUser'. Ensure that the code is valid
But that function is standard from template. Any idea of what I might’ve done wrong? 🙂
a
Are you sure the function is unchanged? Can you share it anways?
v
Yes, I’ll share it
Copy code
type LoggedInUserPayload {
  id: ID!
}

extend type Query {
  # return user data if request contains valid authentication token
  loggedInUser: LoggedInUserPayload
}
Copy code
import { fromEvent, FunctionEvent } from ‘graphcool-lib’
import { GraphQLClient } from ‘graphql-request’

interface User {
  id: string
}

export default async (event: FunctionEvent<{}>) => {
  console.log(event)

  try {
    // no logged in user
    if (!event.context.auth || !event.context.auth.nodeId) {
      return { data: null }
    }

    const userId = event.context.auth.nodeId
    const graphcool = fromEvent(event)
    const api = graphcool.api(‘simple/v1’)

    // get user by id
    const user: User = await getUser(api, userId)
      .then(r => r.User)

    // no logged in user
    if (!user || !user.id) {
      return { data: null }
    }

    return { data: { id: user.id } }
  } catch (e) {
    console.log(e)
    return { error: ‘An unexpected error occured during authentication.’ }
  }
}

async function getUser(api: GraphQLClient, id: string): Promise<{ User }> {
  const query = `
    query getUser($id: ID!) {
      User(id: $id) {
        id
      }
    }
  `

  const variables = {
    id,
  }

  return api.request<{ User }>(query, variables)
}
a
nothing strange there
v
indeed
now that’s weird, I stashed all my changes, and went back to the original schema and code that was working, and I get the same error on this function
Looks like that error is only returned when
--dry-run
is used…
I forced the deploy and all worked
a
Could you create an issue, with DEBUG=* and put your output in there from both commands?
v
Sure
👍🏻 1