Title
v

Vinnie

11/09/2017, 12:42 PM
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
No field with id ‘cj9r95arr00220149vgvgme4d’
a

agartha

11/09/2017, 12:49 PM
Is the former Type still referenced in your permissions/functions?
v

Vinnie

11/09/2017, 12:49 PM
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
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

agartha

11/09/2017, 1:05 PM
Are you sure the function is unchanged? Can you share it anways?
v

Vinnie

11/09/2017, 1:05 PM
Yes, I’ll share it
type LoggedInUserPayload {
  id: ID!
}

extend type Query {
  # return user data if request contains valid authentication token
  loggedInUser: LoggedInUserPayload
}
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

agartha

11/09/2017, 1:07 PM
nothing strange there
v

Vinnie

11/09/2017, 1:09 PM
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

agartha

11/09/2017, 1:18 PM
Could you create an issue, with DEBUG=* and put your output in there from both commands?
v

Vinnie

11/09/2017, 1:18 PM
Sure
👍🏻 1