You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a bit late, and this repository appears to be no longer maintained (#1143), but as we use apollo-server-express which currently uses this GraphQL Playground under the hood, I wanted to know if this was possible, and more so, if variables, headers, etc. could be provided via the url.
You can simply supply the query and endpoint as query params, but If you want to handle variables, headers, etc., you need to use the tabs query parameter, which can handle the following options based on the Tab interface:
endpoint
query
name
variables
responses
headers
The following is an example using all tab options:
constbaseUrl=`https://api.foo.com/playground`// tabs must be an arrayconsttabsData=[{// tab urlendpoint: baseUrl,// tab namename: "User",// tab variables, NOTE: variables are unique in that they must be passed to the VariableEditor as a String, hence JSON.stringifyvariables: JSON.stringify({id: 1}),// tab headersheaders: {authorization: `Bearer 123`},// tab queryquery: ` query UserQuery($id: Int!) { user(id: $id) { id } } `,// tab responsesresponses: [` { "data": { "user": { "id": 1 } } } `,],},]// create tabsQueryParamconsttabsQueryParam=newURLSearchParams({tabs: JSON.stringify(tabsData),}).toString()// concat with baseUrlconsturl=`${baseUrl}?${tabsQueryParam}`// output:// https://api.foo.com/playground?tabs=%5B%7B%22endpoint%22%3A%22https%3A%2F%2Fapi.foo.com%2Fplayground%22%2C%22name%22%3A%22User%22%2C%22variables%22%3A%22%7B%5C%22id%5C%22%3A1%7D%22%2C%22headers%22%3A%7B%22authorization%22%3A%22Bearer+123%22%7D%2C%22query%22%3A%22%5Cn++++++query+UserQuery%28%24id%3A+Int%21%29+%7B%5Cn++++++++user%28id%3A+%24id%29+%7B%5Cn++++++++++id%5Cn++++++++%7D%5Cn++++++%7D%5Cn++++%22%2C%22responses%22%3A%5B%22%5Cn++++++%7B%5Cn++++++++%5C%22data%5C%22%3A+%7B%5Cn++++++++++%5C%22user%5C%22%3A+%7B%5Cn++++++++++++%5C%22id%5C%22%3A+1%5Cn++++++++++%7D%5Cn++++++++%7D%5Cn++++++%7D%5Cn++++%22%5D%7D%5D
From #578, I understand that it's possible to add a query string, something like this:
However, this is the incorrect format. Could the format be added to the README?
This issue pertains to the following package(s):
The text was updated successfully, but these errors were encountered: