Skip to content

Base Query/Mutations #47

Closed
Closed
@j

Description

@j

I was actually working on implementing something similar to this:

https://github.com/j/graphql-party

I just had a complete re-write that I was going to try to push later which has most of the features here, until I saw this library. The code-base is clean and concise and exciting! So good job.

One question that I made sure to implement with my project. Most of my projects have common Query / Mutation functionality. Do you have a query/mutation plugin system or resolver inheritance with the ability to rename fields?

i.e.

// RecipeResolver.ts
@Resolver(objectType => Recipe)
@Use(Deletable, Updatable, Findable)
class RecipeResolver {
  // ...
  @Query(() => Recipe, { array: true })
  favoriteRecipes(): Promise<Array<Recipe>> {
    return this.recipeRepository.findFavorites();
  }
}

// Deletable.ts
function Deletable(name) {
  return class Deletable {
    @Mutation(returnType => Boolean)
    async [`delete${name}`]() {
      // implementation...
    }
  }
]

// Updateable.ts
// ... implementaiton...

// Findable.ts
// ... implementaiton...


// Creates schema:

/*

type Query {
  favoriteRecipes: [Recipe]
  deleteRecipe: Boolean
  Recipe: Recipe
  allRecipes: [Recipe]
}

type Mutation {
  deleteRecipe: Boolean
  updateRecipe: Recipe
}

*/

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions