-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v3] Fixed graphiql ignoring options if GraphiQLOptionFactory returns…
… Promise
- Loading branch information
1 parent
d037c07
commit 21f4020
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,5 @@ | ||
--- | ||
'@graphql-yoga/common': patch | ||
--- | ||
|
||
Fixed graphiql ignoring options if `GraphiQLOptionFactory` returns Promise |
This file contains 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,34 @@ | ||
import { createYoga } from '../server' | ||
|
||
describe('GraphiQL', () => { | ||
describe('when received an option factory that returns Promise', () => { | ||
it('should respect graphiql option', async () => { | ||
const yoga = createYoga({ | ||
graphiql: () => Promise.resolve({ title: 'Test GraphiQL' }), | ||
}) | ||
const response = await yoga.fetch('http://localhost:3000/graphql', { | ||
method: 'GET', | ||
headers: { | ||
Accept: 'text/html', | ||
}, | ||
}) | ||
expect(response.headers.get('content-type')).toEqual('text/html') | ||
const result = await response.text() | ||
expect(result).toMatch(/<title>Test GraphiQL<\/title>/) | ||
}) | ||
|
||
it('returns error when graphiql is disabled', async () => { | ||
const yoga = createYoga({ | ||
graphiql: () => Promise.resolve(false), | ||
}) | ||
const response = await yoga.fetch('http://localhost:3000/graphql', { | ||
method: 'GET', | ||
headers: { | ||
Accept: 'text/html', | ||
}, | ||
}) | ||
expect(response.headers.get('content-type')).not.toEqual('text/html') | ||
expect(response.status).toEqual(406) | ||
}) | ||
}) | ||
}) |
This file contains 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