Skip to content

Compiler error: Error while emitting ... Method too large #700

@rgagne

Description

@rgagne

We have our schema split into user and admin paths. The admin path is largely simple CRUD type operations for managing objects and consist primarily of create/update/delete mutations.

The admin mutation schema looks like:

createObjectKind1(field1, field2, field3.. ) {  .. }
updateObjectKind1(id, field1, field2, field3..) { .. }
etc.

There are roughly 100-200 of these interfaces. Most objects have a handful of fields but some have upwards of 20. We did not nest the fields as objects to avoid writing a lot of marshaling code - since the fields are mostly scalar types marshaling was already handled. We use the deriveContextObjectType macro to instantiate Traits into a schema.

We recently ran into the following error when some additional mutations were added:

scalac: Error while emitting com/fluxweave/graphql/InstanceSchemaAdmin
Method too large: com/fluxweave/graphql/InstanceSchemaAdmin.$anonfun$AdminMutationType$2 (Lcom/fluxweave/graphql/InstanceSchemaAdmin;Lscala/Function1;)Lscala/collection/immutable/List;

After some trial and error we were able to work around it by changing the latest interfaces into:

createObjectKind1(object1 { field1, field2, field3.. }) {  .. }
updateObjectKind1(id, object1 { field1, field2, field3.. }) { .. }

e.g. reduce the number of top level fields

Questions:

  1. Is this a known issue?
  2. Would we run into this if we used the DSL to define the schema vs. the macro?
  3. Is there a better way to resolve this than simplifying the interface?

Code causing the error

class AdminSchema (session: Option[WebSession], ip: RemoteAddress)
  extends QueryBase(session, ip) with QueryAdmin with MutationAdmin {}

class InstanceSchemaAdmin extends SchemaActions {

  val AdminQueryType:ObjectType[AdminSchema, Unit] =
    deriveContextObjectType[AdminSchema, QueryAdmin, Unit](identity)

  val AdminMutationType:ObjectType[AdminSchema, Unit] =
    deriveContextObjectType[AdminSchema, MutationAdmin, Unit](identity)

  val FullSchema:Schema[_,Unit] = Schema(AdminQueryType, Some(AdminMutationType))

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions