flock-community / graphql-simple-bindings

MIT License
2 stars 1 forks source link

Support for union types #9

Open arjovanramshorst opened 4 years ago

arjovanramshorst commented 4 years ago

It appears that there's no support for union types, intentional, or something that can be added?

https://graphql.org/learn/schema/#union-types

Schema that failed:

union Credentials = CollectorAwsCredentials
    | CollectorAzureCredentials

type Collector {
    id: ID!
    name:String!
    type: String!
    accountId: String!
    workspaceId: ID!
    credentials: Credentials!
}

type CollectorAwsCredentials {
    accessKey: String!
    secretKey: String!
}

type CollectorAzureCredentials {
    adDomain: String!
    appId: String
    appKey: String
    enrollmentNumber: String
    enrollmentToken: String
    refreshToken: String
}

Stacktrace:

[ERROR] Failed to execute goal community.flock:graphql-simple-bindings-maven-plugin:0.6.0:generate (default-cli) on project c-facts-service-application: Execution default-cli of goal community.flock:graphql-simple-bindings-maven-plugin:0.6.0:generate failed: This should not happen. New definition? -> UnionTypeDefinition{name='Credentials'directives=[], memberTypes=[TypeName{name='CollectorAwsCredentials'}, TypeName{name='CollectorAzureCredentials'}]} -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal community.flock:graphql-simple-bindings-maven-plugin:0.6.0:generate (default-cli) on project c-facts-service-application: Execution default-cli of goal community.flock:graphql-simple-bindings-maven-plugin:0.6.0:generate failed: This should not happen. New definition? -> UnionTypeDefinition{name='Credentials'directives=[], memberTypes=[TypeName{name='CollectorAwsCredentials'}, TypeName{name='CollectorAzureCredentials'}]}
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal community.flock:graphql-simple-bindings-maven-plugin:0.6.0:generate failed: This should not happen. New definition? -> UnionTypeDefinition{name='Credentials'directives=[], memberTypes=[TypeName{name='CollectorAwsCredentials'}, TypeName{name='CollectorAzureCredentials'}]}
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: community.flock.graphqlsimplebindings.exceptions.DefinitionEmitterException: This should not happen. New definition? -> UnionTypeDefinition{name='Credentials'directives=[], memberTypes=[TypeName{name='CollectorAwsCredentials'}, TypeName{name='CollectorAzureCredentials'}]}
    at community.flock.graphqlsimplebindings.emitter.meta.Emitter.emitDefinition (Emitter.kt:20)
    at community.flock.graphqlsimplebindings.emitter.meta.Emitter.emitDocument (Emitter.kt:11)
    at community.flock.graphqlsimplebindings.emitter.KotlinEmitter.emitDocument (KotlinEmitter.kt:13)
    at community.flock.graphqlsimplebindings.Generator$Companion$emittedWith$1.invoke (Generator.kt:25)
    at community.flock.graphqlsimplebindings.Generator$Companion$emittedWith$1.invoke (Generator.kt:22)
    at community.flock.graphqlsimplebindings.Generator$Companion.mapDoc (Generator.kt:31)
    at community.flock.graphqlsimplebindings.Generator$Companion.emittedWith (Generator.kt:25)
    at community.flock.graphqlsimplebindings.Generator$Companion.access$emittedWith (Generator.kt:22)
    at community.flock.graphqlsimplebindings.Generator.generate (Generator.kt:20)
    at community.flock.graphqlsimplebindings.GeneratorMojo.generateKotlin (GeneratorMojo.kt:56)
    at community.flock.graphqlsimplebindings.GeneratorMojo.generateAll (GeneratorMojo.kt:51)
    at community.flock.graphqlsimplebindings.GeneratorMojo.generate (GeneratorMojo.kt:47)
    at community.flock.graphqlsimplebindings.GeneratorMojo.execute (GeneratorMojo.kt:41)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
[ERROR] 
jerrevanveluw commented 4 years ago

Union types were not considered when thinking about 'simple bindings', but could be added if it fits with the target languages.