diff --git a/router-tests/automatic_persisted_queries_test.go b/router-tests/automatic_persisted_queries_test.go index f02926b034..b9db61c859 100644 --- a/router-tests/automatic_persisted_queries_test.go +++ b/router-tests/automatic_persisted_queries_test.go @@ -23,6 +23,9 @@ func TestAutomaticPersistedQueries(t *testing.T) { t.Run("Sha without query fails", func(t *testing.T) { testenv.Run(t, &testenv.Config{ + RouterOptions: []core.Option{ + core.WithGraphApiToken(""), + }, ApqConfig: config.AutomaticPersistedQueriesConfig{ Enabled: true, }, @@ -36,6 +39,11 @@ func TestAutomaticPersistedQueries(t *testing.T) { t.Run("Sha with query works", func(t *testing.T) { testenv.Run(t, &testenv.Config{ + RouterOptions: []core.Option{ + // This ensures that no CDN client for persistent operations is created, so we can verify that + // APQ alone (without persistent operation support setup) works as expected. + core.WithGraphApiToken(""), + }, ApqConfig: config.AutomaticPersistedQueriesConfig{ Enabled: true, Cache: config.AutomaticPersistedQueriesCacheConfig{ diff --git a/router/internal/persistedoperation/client.go b/router/internal/persistedoperation/client.go index 8c3d81fb46..32780521a6 100644 --- a/router/internal/persistedoperation/client.go +++ b/router/internal/persistedoperation/client.go @@ -78,6 +78,11 @@ func (c client) PersistedOperation(ctx context.Context, clientName string, sha25 return data, false, nil } + if c.providerClient == nil { + // This can happen if we are using APQ client, without any persisted operation client. Otherwise, we should have a provider client and shouldn't reach here. + return nil, c.apqClient != nil, nil + } + content, _, err := c.providerClient.PersistedOperation(ctx, clientName, sha256Hash) if errors.As(err, &PoNotFoundErr) && c.apqClient != nil { // This could well be the first time a client is requesting an APQ operation and the query is attached to the request. Return without error here, and we'll verify the operation later.