abstracting generic type resolving
This commit is contained in:
@ -48,23 +48,30 @@ const client = createClient({
|
||||
},
|
||||
});
|
||||
|
||||
const finalQuery = `
|
||||
subscription {
|
||||
projects_mutated {
|
||||
key
|
||||
event
|
||||
data {
|
||||
${projectsFields}
|
||||
const generateSubscriptionQuery = (typeName) => {
|
||||
const typeDefinition = findTypeDefinition(typeName);
|
||||
const fields = extractFields(typeDefinition);
|
||||
|
||||
return `
|
||||
subscription {
|
||||
${typeName}_mutated {
|
||||
key
|
||||
event
|
||||
data {
|
||||
${fields}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
`;
|
||||
};
|
||||
|
||||
console.log(finalQuery);
|
||||
// Generate subscription query for 'projects'
|
||||
const projectsQuery = generateSubscriptionQuery('projects');
|
||||
// const todosQuery = generateSubscriptionQuery('todos');
|
||||
|
||||
client.subscribe(
|
||||
{
|
||||
query: finalQuery,
|
||||
query: projectsQuery,
|
||||
},
|
||||
{
|
||||
next: data => {
|
||||
|
Reference in New Issue
Block a user