-
Notifications
You must be signed in to change notification settings - Fork 4
[DX-2170] Graphql Playground Guide #1012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
79fc858
Fixes
sharadregoti 6bf9541
Merge branch 'main' of https://github.com/TykTechnologies/mintlify-poc
sharadregoti c9d0cb4
Merge branch 'main' of https://github.com/TykTechnologies/mintlify-poc
sharadregoti 4222e6a
Merge branch 'main' of https://github.com/TykTechnologies/mintlify-poc
sharadregoti 3aed873
Merge branch 'main' of https://github.com/TykTechnologies/mintlify-poc
sharadregoti 86fb7dc
Merge branch 'main' of https://github.com/TykTechnologies/mintlify-poc
sharadregoti 1352b96
Merge branch 'main' of https://github.com/TykTechnologies/mintlify-poc
sharadregoti 113085e
Merge branch 'main' of https://github.com/TykTechnologies/mintlify-poc
sharadregoti 7503180
Merge branch 'main' of https://github.com/TykTechnologies/mintlify-poc
sharadregoti 3ea966f
Merge branch 'main' of https://github.com/TykTechnologies/mintlify-poc
sharadregoti a9312cc
Merge branch 'main' of https://github.com/TykTechnologies/mintlify-poc
sharadregoti 6f26268
Merge branch 'main' of https://github.com/TykTechnologies/mintlify-poc
sharadregoti c0e4d0b
Merge branch 'main' of https://github.com/TykTechnologies/mintlify-poc
sharadregoti b862450
Merge branch 'main' of https://github.com/TykTechnologies/mintlify-poc
sharadregoti 7bd0062
Merge branch 'main' of https://github.com/TykTechnologies/mintlify-poc
sharadregoti 3efeafc
Merge branch 'main' of https://github.com/TykTechnologies/mintlify-poc
sharadregoti 77e5dfb
Fixes
sharadregoti ed15bb0
F
sharadregoti 7f689c5
Merge main into DX-2170
buger e4031dc
Fixes
sharadregoti b48ae60
Merge main into DX-2170
buger 3bcd9a4
Fixes
sharadregoti db73ae8
Merge branch 'DX-2170' of https://github.com/TykTechnologies/mintlify…
sharadregoti a3d22ea
F
sharadregoti de279e6
F
sharadregoti 7fa2110
F
sharadregoti 072a15e
F
sharadregoti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| --- | ||
| title: "How to Set Up the GraphQL Playground" | ||
| description: "Learn how to set up and use the GraphQL Playground in the Tyk Developer Portal" | ||
| keywords: "Tyk Developer Portal, GraphQL Playground, GraphQL API, API Documentation, Interactive API Testing" | ||
| sidebarTitle: "GraphQL Playground" | ||
| --- | ||
|
|
||
| ## Availability | ||
|
|
||
| | Component | Version | Editions | | ||
| | :------------- | :---------------------- | :------------------------- | | ||
| | Developer Portal | Available since [v1.15.0](/developer-support/release-notes/portal#1-15-0-release-notes) | Enterprise | | ||
|
|
||
|
|
||
| ## Prerequisites | ||
|
|
||
| - **Dashboard License**: We will configure GraphQL API using Dashboard. [Contact our team](https://tyk.io/contact/) to obtain a license or get self-managed trial license by completing the registration on our [website](https://tyk.io/self-managed-trial/). | ||
| - **Working Tyk Environment:** You need access to a running Tyk instance that includes both the Tyk Gateway and Tyk Dashboard components. For setup instructions using Docker, please refer to the [Tyk Getting Started Guide](/getting-started/quick-start). | ||
| - Tyk Developer Portal v1.15.0 or later | ||
|
|
||
| ## Instructions | ||
|
|
||
| Follow these steps to set up the GraphQL Playground in the Tyk Developer Portal: | ||
|
|
||
| ### 1. Create a GraphQL API | ||
|
|
||
| 1. In the **Tyk Dashboard**, create a new **GraphQL API** by | ||
|
|
||
| - Navigating to **APIs > Add New API** | ||
| - In the next screen, click on **Try example** and select **Star Wars GQL API** from the list. | ||
| - Click **Use Example** to create the API. | ||
| - **Star Wars GQL API** uses [Auth Token](/api-management/authentication/bearer-token) for authentication. Copy the **Key ID** from the pop-up and save it for later use. We will set the authorization header in the Playground using this Key ID. | ||
|
|
||
| 2. Now, go to the **Schema** tab and download the schema. | ||
|
|
||
| This schema file will be uploaded to the Developer Portal in a later step. | ||
|
|
||
| <img src="/img/graphql-api-star-wars-schema.png" alt="GraphQL API Schema Tab" /> | ||
|
|
||
| ### 2. Create the API Catalog | ||
|
|
||
| The Tyk Getting Started Guide creates an API Catalog (`Public catalogue`) by default. If you don't have one, refer to this [guide](/portal/publish-api-catalog#step-1:-create-the-api-catalog) to create an API Catalog in the Developer Portal. | ||
|
|
||
| ### 3. Create an API Product | ||
|
|
||
| 1. Navigate to **Developer Portal > API Products** | ||
| 2. Click **Add new API Product** | ||
| <img src="/img/dashboard/portal-management/enterprise-portal/portal-add-api-product.png" alt="Add an API Product" /> | ||
| 3. On the **Details** tab, enter the basic product information: | ||
| <img src="/img/dashboard/portal-management/enterprise-portal/portal-product-details.png" alt="Configure API Product details" /> | ||
| - Product name: A unique product name (e.g., "Star Wars") | ||
| - Publish API product to catalogue: Select the catalog you created [previously](#2-create-the-api-catalog) | ||
| - You can leave the other fields empty for now | ||
| 4. On the **APIs** tab, select the `Star Wars GQL API` created in the [first step](#1-create-a-graphql-api): | ||
| 5. On the **Documentation** tab: | ||
| - Add your **GraphQL API endpoint URL** (e.g `http://localhost:8080/star-wars-api/`). | ||
|
|
||
| <Note> | ||
| You can find the endpoint URL in the **Core Settings** tab of your GraphQL API in the Dashboard. | ||
| </Note> | ||
|
|
||
| - Upload a GraphQL SDL file (in .graphql, .graphqls, .gql, or JSON format) | ||
| <Note> | ||
| By default, the GraphQL playground will introspect the schema from the endpoint if no SDL file is provided. However, if the API is protected, introspection will not work, and the schema will be rendered from the uploaded SDL file. | ||
| </Note> | ||
| <img src="/img/graphql-docs-tab-playground-setup.png" alt="GraphQL API Product Documentation Tab" /> | ||
| 6. Click **Save Changes** | ||
|
|
||
| ### 4. View the Playground | ||
|
|
||
| 1. Open your **Live Portal**. | ||
| 2. Go to **Product Catalogues**, locate your GraphQL Product and Click **Docs**. | ||
| <img src="/img/graphql-docs-live-portal.png" alt="GraphQL API Docs Live Portal" /> | ||
| 3. You should now see the **GraphQL Playground**, ready for interactive query testing. | ||
|
|
||
| <Note> | ||
|
|
||
| To test authenticated APIs, ensure you set the required authentication headers in the Playground according to your API's authentication settings. | ||
|
|
||
| For example, for the `Star Wars GQL API`, add the `Authorization` header with the value `Bearer <Key ID>` where `<Key ID>` is the token you saved earlier. | ||
|
|
||
| ```json | ||
| { | ||
| "Authorization": "Bearer YOUR_KEY_ID" | ||
| } | ||
| ``` | ||
| </Note> | ||
|
|
||
|
|
||
| <img src="/img/graphql-playground-portal.png" alt="GraphQL API Playground" /> | ||
|
|
||
sharadregoti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ## Troubleshooting | ||
|
|
||
| <AccordionGroup> | ||
|
|
||
| <Accordion title='404 GraphQL API Not Found Error in Playground'> | ||
| If you encounter a `404 GraphQL API Not Found` error in the GraphQL Playground, it indicates that the Developer Portal cannot locate the specified GraphQL API. | ||
|
|
||
| To resolve this issue, ensure that your API ends with a trailing slash (`/`). (e.g `http://localhost:8080/star-wars-api/`) | ||
|
|
||
| <Note> | ||
| You can find the endpoint URL in the **Core Settings** tab of your GraphQL API in the Dashboard. | ||
| </Note> | ||
|
|
||
| </Accordion> | ||
|
|
||
| <Accordion title='"message": "Failed to fetch" error in Playground'> | ||
|
|
||
| If you are seeing a `"message": "Failed to fetch"` error in the GraphQL Playground, it is likely due to CORS (Cross-Origin Resource Sharing) restrictions. To resolve this issue, follow these steps: | ||
|
|
||
| Go to the Dashboard, and add the following CORS configuration to your GraphQL API settings: | ||
|
|
||
| ```json | ||
| "CORS": { | ||
| "enable": true, | ||
| "max_age": 24, | ||
| "allow_credentials": true, | ||
| "exposed_headers": [ | ||
| "*" | ||
| ], | ||
| "allowed_headers": [ | ||
| "*" | ||
| ], | ||
| "options_passthrough": true, | ||
| "debug": false, | ||
| "allowed_origins": [ | ||
| "http://localhost:3001" | ||
| ], | ||
| "allowed_methods": [] | ||
| }, | ||
| ``` | ||
|
|
||
| - Ensure that the `allowed_origins` field includes the URL of your Developer Portal (e.g., `http://localhost:3001` for local setups). | ||
|
|
||
| </Accordion> | ||
|
|
||
| </AccordionGroup> | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.