Open ShibyNiju opened 1 year ago
Hello, can you provide a very basic example? you can modify the basic example in our samples directory, So we can add support of namespaces. Thanks for the good feedback.
Shall i quote the example here? Microservice 1 - user1 - user_get Microservice 2 - user2 - user_get
So when merging Microservice 1 and Microservice 2 with schema names user1 and user2 respectively, now error occurs. Schema name can be used as a namespace and store the 2 queries in the merged schema.
Ok. I'll examine it and get back to you. Thanks.
Ok, I want to learn about your practical usage about this. I have tried with Atlassian braid.
final String graphqlTypeDefinition = "type Query {\n" +
" user_get: String!\n" +
"}\n";
final Braid braid = Braid.builder()
.schemaSource(QueryExecutorSchemaSource.builder()
.namespace(SchemaNamespace.of("namespace1"))
.schemaLoader(new StringSchemaLoader(SchemaLoader.Type.IDL, graphqlTypeDefinition))
.localRetriever(new Function<Query, Object>() {
@Override
public Object apply(final Query query) {
return ImmutableMap.of("user_get1100", "admin");
}
})
.build())
.schemaSource(QueryExecutorSchemaSource.builder()
.namespace(SchemaNamespace.of("namespace2"))
.schemaLoader(new StringSchemaLoader(SchemaLoader.Type.IDL, graphqlTypeDefinition))
.localRetriever(new Function<Query, Object>() {
@Override
public Object apply(final Query query) {
return ImmutableMap.of("user_get1100", "user");
}
})
.build())
.build();
String query = "{user_get}";
final ExecutionResult result = braid.newGraphQL().execute(newExecutionInput().query(query).build()).join();
and getting java.lang.IllegalStateException: Duplicate key Query.user_get
error.
For such scenario what are your type definitions and what is your query?
In braid, there is a namespace concept. This will make possible to define graphql query with same name to be created in different microservices. Similarly, the schema in lilo should also considered while merging the graphql queries from different microservices. Now a duplicate exception occurs if there are similar named queries in different microservices while merging the schema