Search code examples
ruby-on-railsexcelrubygraphqlgraphql-ruby

Where should I put the requests related to excel export/import on Graphql?


I have an architectural doubt.

I am using the GraphQL as an API provider and I need to develop some API requests to import data from excel and to export data to excel on my project.

Where should I create this using the GraphQL API?

I researched and discovered it is possible to create customized queries and mutations on the GraphQL... In this case...

  • This should be a query?
  • This should be a mutation?
  • Or other thing?

Side note: I am using the GraphQL API on my Ruby on Rails project via the graphql-ruby gem and I am also using the mongoid gem to deal with the database.


Solution

  • Comparing to REST API this is how it should be

    REST GrapQL
    GET GrapQL Query
    POST, PUT, PATCH, DELETE GrapQL Mutation

    If you are just querying go for GraphQL Query If you are modifying the data use Mutations

    In your case import should be mutation whereas export can be query

    Read more - here