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

How to use custom methods? #37

Open
sneerin opened this issue Oct 20, 2017 · 1 comment
Open

How to use custom methods? #37

sneerin opened this issue Oct 20, 2017 · 1 comment
Labels

Comments

@sneerin
Copy link

sneerin commented Oct 20, 2017

I really like the project. The sample project doesn't have much about virtual fields and custom methods.

@igorlesnenko
Copy link
Member

igorlesnenko commented Oct 24, 2017

Hi @sneerin ! Thanks for the interest in this project!
Custom methods and mutations are not implemented yet.

Example of virtual fields could be found in the section "core concepts" of README.md file
https://github.com/spikenail/spikenail#core-concepts

Field should be marked as virtual:

    virtualField: {
      virtual: true,
      // Ensure dependent fields to be queried from the database
      dependsOn: ['position'],
      type: String
    },

and you need to add custom resolver for that:

  // Custom resolvers
  resolvers: {
    description: async function(_, args) {
      // It is possible to do some async actions here
      let asyncActionResult = await someAsyncAction();
      return asyncActionResult ? _.description : null;
    },
    virtualField: (_, args) => {
      return 'justCustomModification' + _.position
    }
  },

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

No branches or pull requests

2 participants