I’m using graphql with my stack and one of the convienent development endpoints is graphiql which points to the POST graphql endpoint for testing queries. However, I only want to use this endpoint during development, i.e. sls offline start.
Is there a way to conditionally deploy API Gateway endpoints?
Maybe. If you can it’s going to look something like this.
default_functions: &default_functions
# Put your function definitions here (except graphiql)
dev_functions:
<<: *default_functions
# Add the definitions for graphiql here
prod_functions:
<<: *default_functions
functions: ${self:${self:custom.stage}_functions}
What you’re doing is:
Setting up default_functions with all of your functions except graphiql
Setting up a section for each each stage dev_functions and prod_functions that inherits the values from default_functions then you’re adding graphiql to only the dev_functions stage.
Setting up functions to inherit from the functions for the current stage (dev_functions or prod_functions).