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

opaque json mappping #460

Closed
wants to merge 4 commits into from
Closed

opaque json mappping #460

wants to merge 4 commits into from

Conversation

tpolecat
Copy link
Member

This adds an opaque: Boolean = false argument to the constructors for mappings that are backed by CirceCursor. If this field if true then the underlying JSON is considered to be the final result and no attempt is made to hop into other mappings if another mapped type is encountered during traversal. The use case is a deep structure that appears twice as a return type in the schema, served in one place by a SQL mapping and in another place by a computed JSON mapping.

This also turns off BSP processing for non-JVM projects. I think this may have already been done on another branch.

build.sbt Outdated
@@ -121,6 +121,7 @@ lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.5.0",
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule))
)
.platformsSettings(JSPlatform, NativePlatform)(bspEnabled := false)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe bsp was turned off a different way in #458

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool I'll undo that.

@milessabin
Copy link
Member

Can't this be achieved with a PrefixMapping?

@tpolecat
Copy link
Member Author

Can't this be achieved with a PrefixMapping?

Yes, but you need a PrefixMapping for every type in the subtree, which in our particular case is a lot. You can also do this by overriding mkCursorForField in your Mapping to treat all CirceCursors this way (which is what we have done), so if this change isn't sensible we can fall back to that.

@milessabin
Copy link
Member

Yes, but you need a PrefixMapping for every type in the subtree

That's bad, agreed. But maybe we can come up with a generalization of PrefixMapping which could do the job more straightforwardly? What is the condition that determines whether the circe cursor should be used? Could we express that as a more general predicate than a path prefix?

@tpolecat
Copy link
Member Author

What is the condition that determines whether the circe cursor should be used?

In our case it's universal (if the parent is a circe cursor then the child should also be a circe cursor) but more generally if the path from the root is X/Y/Z then all children should be circe cursors. The solution I propose here marks this at the parent node X/Y/Z rather than marking it at all child nodes X/Y/Z/**/Q.

@milessabin
Copy link
Member

See #461.

@milessabin
Copy link
Member

Superseded by #565.

@milessabin milessabin closed this Feb 23, 2024
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

Successfully merging this pull request may close these issues.

4 participants