Implementing a live directive
Opened this issue · 2 comments
eljenso commented
I'm trying to implement a live directive, which keeps the caller of the query up-to-date.
This is my current code, which does just resolve()
with the directive.
const typeDefs = /* GraphQL */ `
directive @live on FIELD | FIELD_DEFINITION
type Todo {
text: String!
completed: Boolean!
}
type Query {
allTodos: [Todo]! @live
}
`;
const resolvers = {
Query: {
allTodos() {
return someTodoArray;
}
}
};
const executableSchema = makeExecutableSchema({
typeDefs,
resolvers
});
addDirectiveResolveFunctionsToSchema(executableSchema, {
live(resolve) {
return resolve();
}
});
How would I push new results to the caller with this approach?
Is there a way to get a reference to the caller to push new results?
giautm commented
@eljenso : Hi, please trying to use new feature in graphql-tools, https://www.apollographql.com/docs/graphql-tools/schema-directives.html