Skip to content
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

Empty response cache with Cloudflare workers and KV #5171

Open
smakhtin opened this issue Feb 22, 2023 · 0 comments
Open

Empty response cache with Cloudflare workers and KV #5171

smakhtin opened this issue Feb 22, 2023 · 0 comments

Comments

@smakhtin
Copy link

smakhtin commented Feb 22, 2023

Trying to use response caching with Cloudflare workers and KV. Cache entries are created in KV, but cache never hit and in Cloudflare console i can see that cached data is empty json ({}).

Config:

sources:
  - name: TheGraph
    handler:
      graphql:
        endpoint: '{{&GRAPHQL_ENDPOINT}}'
  - name: Pinata
    handler:
      jsonSchema:
        endpoint: 'https://sni.mypinata.cloud/'
        operations:
          - type: Query
            field: ipfsMetadata
            path: /ipfs/{args.cid}
            method: GET
            responseSchema: ./json-schemas/metadata.json
        operationHeaders:
          x-pinata-gateway-token: '{{&PINATA_TOKEN}}'
    transforms:
      - resolversComposition:
          mode: bare
          compositions:
            - resolver: 'Query.ipfsMetadata'
              composer: './middleware/getCid.ts'
additionalTypeDefs: |
  extend type SNI {
    metadata: Identifier_Token_Metadata
  }
additionalResolvers:
  - targetTypeName: SNI
    targetFieldName: metadata
    sourceName: Pinata
    sourceTypeName: Query
    sourceFieldName: ipfsMetadata
    requiredSelectionSet: |
      {
        tokenURI
      }
    sourceArgs:
      cid: '{root.tokenURI}'
plugins:
  - responseCache:
      includeExtensionMetadata: true
cache:
  cfwKv:
    namespace: MESH

Deployed gateway - https://gateway-staging.sovereignnature.ch/graphql.

Example response:

{
	"data": {
		"sni": {
			"id": "0x0"
		}
	},
	"extensions": {
		"responseCache": {
			"hit": false,
			"didCache": true,
			"ttl": null
		}
	}
}

Cloudflare console:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant