graphprotocol / graph-client

The Graph library for building GraphQL-based dapps in a decentralized way.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using a custom source SDL

shlomich opened this issue · comments

Hello,

I have this data in my graphclient.yml

sources:
  - name: defined_http
    handler:
      graphql:
        endpoint: http://api.defined.fi
        operationHeaders:
          x-api-key: <any_api_key>

Now, this fails when it tries to do introspection for some reason, I saw in https://the-guild.dev/graphql/mesh/docs/handlers/graphql#config-api-reference that u can set a source.

So I set it to

sources:
  - name: defined
    handler:
      graphql:
        endpoint: https://api.defined.fi
        operationHeaders:
          x-api-key: <any_api_key>
        source: './libs/shared/schemas/src/graphql/sdl.graphql'

I copied the SDL from https://studio.apollographql.com/public/Public-Api-h6jqqg/schema/sdl?variant=public and put it into sdl.graphql file.

Then I'm getting this when trying to build

 GraphClient - config Configuration file is not valid!
⚠️ GraphClient - config This is just a warning! It doesn't have any effects on runtime.
⚠️ GraphClient - config must NOT have additional properties
⚠️ GraphClient - config must have required property 'schema'
⚠️ GraphClient - config must have required property 'sources'
⚠️ GraphClient - config must match a schema in anyOf

but that source file does have what is needed. It has all the properties and what is needed. Can anyone maybe try and see if you manage to get it working? or am I missing something?

The best result would be having it work with the URL but it keeps giving me

 Failed to generate the schema Error: Failed to fetch introspection from https://api.defined.fi: GraphQLError: Could not obtain introspection result, received the following as response; 
 { message: "Forbidden" }

Even though through the console itself (https://docs.defined.fi/explore), the introspection query works.

EDIT:
I solved the introspection, I was using operationHeaders while I needed schemaHeaders in order to fetch the schema without getting a forbidden message. so the SDL is not needed.