serverless-appsync-plugin
serverless-appsync-plugin copied to clipboard
[Feature-Request] Add Graphql endpoint to sls graphql-playground
When developping in local, it is helpful to specify graphql endpoint to local endpoint.
So, how about adding --endpoint arguments to sls graphql-playground
?
Changing like this.
index.js
'graphql-playground': {
usage: 'Runs a local graphql playground instance using your appsync config',
options: {
clientId: {
usage: 'Specify your cognito client id (for AMAZON_COGNITO_USER_POOLS authType)',
required: false,
},
username: {
usage: 'Specify your username (for AMAZON_COGNITO_USER_POOLS authType)',
shortcut: 'u',
required: false,
},
password: {
usage: 'Specify your password (for AMAZON_COGNITO_USER_POOLS authType)',
shortcut: 'p',
required: false,
},
jwtToken: {
usage: 'Specify your jwtToken (for OPENID_CONNECT authType)',
required: false,
},
apiKey: {
usage: 'Specify your appsync api key (for API_KEY authType)',
required: false,
},
port: {
usage: 'Specify the local port graphql playground should run from',
required: false,
},
},
lifecycleEvents: ['run'],
},
'graphql-playground': {
usage: 'Runs a local graphql playground instance using your appsync config',
options: {
clientId: {
usage: 'Specify your cognito client id (for AMAZON_COGNITO_USER_POOLS authType)',
required: false,
},
username: {
usage: 'Specify your username (for AMAZON_COGNITO_USER_POOLS authType)',
shortcut: 'u',
required: false,
},
password: {
usage: 'Specify your password (for AMAZON_COGNITO_USER_POOLS authType)',
shortcut: 'p',
required: false,
},
jwtToken: {
usage: 'Specify your jwtToken (for OPENID_CONNECT authType)',
required: false,
},
apiKey: {
usage: 'Specify your appsync api key (for API_KEY authType)',
required: false,
},
port: {
usage: 'Specify the local port graphql playground should run from',
required: false,
},
endpoint: {
usage: 'Specify your GraphQL endpoint',
required: false,
},
},
lifecycleEvents: ['run'],
},
graphql-playground.js
return Promise.all([
getHeaders(service, provider, config, options),
getOutputValue(service, provider, 'GraphQlApiUrl'),
])
return Promise.all([
getHeaders(service, provider, config, options),
options.endpoint || getOutputValue(service, provider, 'GraphQlApiUrl'),
])
Why not do this yourself and open a PR?
Thanks @honasassa for the suggestion. Feel free to open an PR for that. Also, I was thinking that it might be interesting to make this play nicely along with https://github.com/bboure/serverless-appsync-simulator
For example, if the simulator is started, we might detect that and, optionally, start graphql-playground
with the simulator's endpoint.