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

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

Open
rgagne opened this issue Jul 22, 2021 · 0 comments
Open

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

rgagne opened this issue Jul 22, 2021 · 0 comments

Comments

@rgagne
Copy link

rgagne commented Jul 22, 2021

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))

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant