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

Namespace concept as in Braid #19

Open
ShibyNiju opened this issue Apr 12, 2023 · 4 comments
Open

Namespace concept as in Braid #19

ShibyNiju opened this issue Apr 12, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@ShibyNiju
Copy link

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

@firatkucuk
Copy link
Collaborator

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.

@ShibyNiju
Copy link
Author

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.

@firatkucuk
Copy link
Collaborator

Ok. I'll examine it and get back to you. Thanks.

@firatkucuk firatkucuk self-assigned this Apr 12, 2023
@firatkucuk firatkucuk added the enhancement New feature or request label Apr 12, 2023
@firatkucuk
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants