n1ru4l/graphql-schema-generator-rest

Add option to specify base uris

Open

#114 opened on May 14, 2018

 (0 comments) (0 reactions) (0 assignees)JavaScript (6 forks)auto 404
good first issuehelp wanted

Repository metrics

Stars
 (95 stars)
PR merge metrics
 (PR metrics pending)

Description

Instead of supplying the schema string with lots of urls strings (that are mostly the same) it should be possible to shorten them. Also in case of a refactor there would be less code to change.

Idea:

new (object literal/string) option for function generateRestSchema: baseUri.

Case 1: baseUriis a string

import { generateRestSchema } from '@n1ru4l/graphql-schema-generator-rest'

generateRestSchema({ baseUri: `https://localhost:8080` })

Every route directive option that does not start with a scheme (e.g. https://, http:// is prefixed with the baseUri

Case 2: baseUri is a object literal:

import { generateRestSchema } from '@n1ru4l/graphql-schema-generator-rest'

generateRestSchema({ baseUri: {
  dogs: `https://localhost:8080`,
  cats: `https://localhost:8081`
} })

Every route directive option that does not start with a scheme (e.g. https://, http://) but has a uri directive option which matches a key of the baseUri option object is prefixed with the corresponding value.

Contributor guide