-
Notifications
You must be signed in to change notification settings - Fork 221
Description
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:
- Is this a known issue?
- Would we run into this if we used the DSL to define the schema vs. the macro?
- 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))
}