-
Notifications
You must be signed in to change notification settings - Fork 54
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
Create custom additional query #262
Comments
Could someone answer, please? |
i added a some code to do it: public abstract class SchemaBuilderHelper {
private final String path;
public SchemaBuilderHelper(final String path) {
this.path = path;
}
public GraphQLSchema buildSchema() {
try (final var reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(path)))) {
return new SchemaGenerator().makeExecutableSchema(
new SchemaParser().parse(reader),
buildWiring());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
protected abstract RuntimeWiring buildWiring();
} then extends class: @Component
public class XxxSchemaBuilder extends SchemaBuilderHelper {
private static final String PATH = "/gql/xxx.graphqls";
@Autowired
private XxxDataFetcher xxxDataFetcher;
public XxxSchemaBuilder() {
super(PATH);
}
@Override
protected RuntimeWiring buildWiring() {
return RuntimeWiring.newRuntimeWiring()
.type("Mutation", typeWiring ->
typeWiring
.dataFetcher("updateXxx", xxxDataFetcher.updateXxx())
)
.build();
}
} then register it in schema: @Override
public void configure(final GraphQLShemaRegistration registry) {
registry.register(graphQLSchemaBuilder()
.build());
registry.register(xxxSchemaBuilder.build());
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I need to add custom queries to those auto-generated from the schema.
I write my
.graphqls
file with only a query inside and aGraphQLQueryResolver
to resolve the query but the query is not added in the schema and I can't call it.I didn't define the type in the
.graphqls
file because the type is autogenerated from the db schema.What am I doing wrong?
The text was updated successfully, but these errors were encountered: