Skip to content

ysksn/words

Repository files navigation

README

This is a rails app using GraphQL to query and mutate resources.

Install

git clone git@github.com:ysksn/words.git

bundle install

bundle exec rails db:setup

Usage

bundle exec rails s

Open a browser and go to localhost.

Query

Please pass a fullPath of URL as an argument where you want to retrieve words of paragraphs.

key value type required?
fullPath URL String true
order ("desc"|"asc") String false
limit num of words Int false
(limit cannot exceed 100.)
{
  words(fullPath: "http://www.sccsc.jp/", order: "desc", limit: 5) {
    word
    count
  }
}

result

{
  "data": {
    "words": [
      {
        "word": "訓練",
        "count": 8
      },
      {
        "word": "",
        "count": 8
      },
      {
        "word": "職業",
        "count": 5
      },
      {
        "word": "",
        "count": 5
      },
      {
        "word": "ハロー",
        "count": 4
      }
    ]
  }
}

Mutation

mutation crawlWords($input: CrawlWordsInput!) {
  crawlWords(input: $input) {
    source {
      fullPath
      crawledAt
    }
    errors
  }
}

query variables

Please pass a fullPath of URL as an argument where you want to crawl words of paragraphs.

key value type required?
fullPath URL String true
{
  "input": {
    "fullPath": "http://www.sccsc.jp/"
  }
}

result

{
  "data": {
    "crawlWords": {
      "source": {
        "fullPath": "http://www.sccsc.jp/",
        "crawledAt": "2018-10-01 18:02:17 +0900"
      },
      "errors": []
    }
  }
}

Test

bundle exec rspec

About

My first GraphQL project :)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages