Skip to content
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

Stacktrace TypeError: Cannot use 'in' operator to search for 'raw' in * #65

Open
Teomayo opened this issue Jun 8, 2021 · 2 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@Teomayo
Copy link

Teomayo commented Jun 8, 2021

Below is a general purpose UDF for creating a document in a given collection. The function was successfully created and tested in the Fauna environment, and looks like the following:

import faunadb from 'faunadb'

const q = faunadb.query
const { CreateFunction, Query, Var, Lambda, Create, Collection } = q


export default create_doc = CreateFunction({
  name: "createDoc",
  body: 
    Query(
      Lambda(
        ["collection", "doc_data", "doc_name"],
        Create(
            Collection(Var("collection")), {
                data: { 
                    doc_name: Var("doc_name"), 
                    doc_data: Var("doc_data") 
                }
            }
        )
      )
    )
  }
);

However, when creating the infrastructure for it and attempting to generate the migration for it, I am met with the following error:
image

Any help on this error would be appreciated.

@Gozala
Copy link

Gozala commented Jun 11, 2021

Running into this issue with following below function as well

CreateFunction({
  name: 'clearCollection',
  body: Query(
    Lambda(
      ["name"],
      Foreach(
        Paginate(Documents(Collection(Var("name")))),
        Lambda(["ref"], Delete(Var("ref")))
      )
    )
  )
});

@rts-rob
Copy link
Contributor

rts-rob commented Jun 15, 2021

Thanks for reporting; this is happening somewhere in the call to Collection().

If possible, one suggested solution to both is to migrate to the Serverless Framework plugin we've recently launched in beta, as this is expected to be fully supported in the near future (less than one month).

The specific case @Teomayo reports can be worked around by using the collection name as a string rather than an object, e.g.,:

        Create(
            Var("collection"), {

Unfortunately this doesn't work for @Gozala 's case - you can remove the call to Collection() and FSM (incorrectly) creates the function, but you can't call it as Documents() expects a Ref, not a string.

@rts-rob rts-rob self-assigned this Aug 31, 2021
@rts-rob rts-rob added the bug Something isn't working label Aug 31, 2021
rts-rob added a commit that referenced this issue Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants