0.3.18 • Published 3 years ago

launchql-gen v0.3.18

Weekly downloads
19
License
SEE LICENSE IN LI...
Repository
github
Last release
3 years ago

launchql-gen

Generate GraphQL mutations/queries

npm install launchql-gen

introspecting via GraphQL

import {
  generate
} from 'launchql-gen';
import { print } from 'graphql/language';

const gen = generate(resultOfIntrospectionQuery);
const output = Object.keys(gen).reduce((m, key) => {
  m[key] = print(gen[key].ast);
  return m;
}, {});

console.log(output);

output

which will output the entire API as an object with the mutations and queries as values

{
  "createApiTokenMutation": "mutation createApiTokenMutation($id: UUID, $userId: UUID!, $accessToken: String, $accessTokenExpiresAt: Datetime) {
  createApiToken(input: {apiToken: {id: $id, userId: $userId, accessToken: $accessToken, accessTokenExpiresAt: $accessTokenExpiresAt}}) {
    apiToken {
      id
      userId
      accessToken
      accessTokenExpiresAt
    }
  }
}