Skip to content

Instantly share code, notes, and snippets.

@DanielEFrampton
Last active April 6, 2020 19:19
Show Gist options
  • Save DanielEFrampton/15f42f3e6a0e508ad76178add35f17cb to your computer and use it in GitHub Desktop.
Save DanielEFrampton/15f42f3e6a0e508ad76178add35f17cb to your computer and use it in GitHub Desktop.
Rosetta Example GraphQL Queries & Responses

POST https://rosetta-be.herokuapp.com/graphql

Body:

getLanguagesAndMethods() {
  languages {
    name
    methods {
      name
      description
    }
  }
}
[
  {
    languageName: 'Ruby',
    methods: [
      {
        name: '.split',
        description: 'splits string into array'
      },
      {
        name: '.map',
        description: 'iterates over array and returns array of return values'
      }
    ]
  },
  {
    languageName: 'JavaScript',
    methods: [
      {
        name: '.split',
        description: 'splits string into array'
      },
      {
        name: '.map',
        description: 'iterates over array and returns array of return values'
      }
    ]
  }
]
getTranslatedMethods(sourceLang: 'Ruby', targetLang: 'JS', methodName: 'split') {
  methods {
    name
    docsUrl (ruby: anchor tag for specific method, JS: page for that method)
    syntax
    snippet
    description
    relevance
  }
}
[
  {
    name: 'map',
    docsUrl: 'mdndocs.com/JS/map',
    syntax: 'thing(thing1, thing2)',
    snippet: 'some code',
    description: 'iterates over array and returns array of return values',
    relevance: 0.91
  },
  {
    name: 'map',
    docsUrl: 'mdndocs.com/JS/map',
    syntax: 'thing(thing1, thing2)',
    snippet: 'some code',
    description: 'iterates over array and returns array of return values',
    relevance: 0.65
  },
  {
    name: 'map',
    docsUrl: 'mdndocs.com/JS/map',
    syntax: 'thing(thing1, thing2)',
    snippet: 'some code',
    description: 'iterates over array and returns array of return values',
    relevance: 0.99
  },
  {
    name: 'map',
    docsUrl: 'mdndocs.com/JS/map',
    syntax: 'thing(thing1, thing2)',
    snippet: 'some code',
    description: 'iterates over array and returns array of return values',
    relevance: 0.43
  },
  {
    name: 'map',
    docsUrl: 'mdndocs.com/JS/map',
    syntax: 'thing(thing1, thing2)',
    snippet: 'some code',
    description: 'iterates over array and returns array of return values',
    relevance: 0.21
  }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment