Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Apr 17, 2022
1 parent 3c2986f commit 02a67dc
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/common/src/processRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,20 @@ export async function processRequest<TContext>({
})
}

if (extensions?.persistedQuery != null && persistedQueryStore == null) {
return getErrorResponse({
status: 500,
errors: [new GraphQLError('PersistedQueryNotSupported')],
isEventStream,
headers: extraHeaders,
})
}

if (query == null) {
if (
persistedQueryStore != null &&
extensions?.persistedQuery?.version === 1 &&
extensions?.persistedQuery?.sha256Hash
extensions?.persistedQuery?.sha256Hash != null &&
persistedQueryStore != null
) {
const persistedQuery = await persistedQueryStore.get(
extensions?.persistedQuery?.sha256Hash,
Expand All @@ -239,9 +248,9 @@ export async function processRequest<TContext>({
})
}
} else if (
persistedQueryStore != null &&
extensions?.persistedQuery?.version === 1 &&
extensions?.persistedQuery?.sha256Hash
extensions?.persistedQuery?.sha256Hash != null &&
persistedQueryStore != null
) {
if (crypto) {
const encodedQuery = encodeString(query)
Expand All @@ -256,9 +265,7 @@ export async function processRequest<TContext>({
if (extensions.persistedQuery.sha256Hash !== expectedHashString) {
return getErrorResponse({
status: 400,
errors: [
new GraphQLError('PersistedQuery signature does not match'),
],
errors: [new GraphQLError('PersistedQueryInvalidHash')],
isEventStream,
headers: extraHeaders,
})
Expand Down

0 comments on commit 02a67dc

Please sign in to comment.