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

Introspection #22

Open
acdoyle630 opened this issue Apr 11, 2022 · 3 comments
Open

Introspection #22

acdoyle630 opened this issue Apr 11, 2022 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@acdoyle630
Copy link

acdoyle630 commented Apr 11, 2022

Hi team, I'm trying to introspect a gql-gateway generated server from an ApolloServer but I am getting a 400 bad request when trying to spin up the ApolloServer with subgraphs. Wondering if theres a config or something that I'm missing?

Thanks!

gql-gateway server

import gateway from 'gql-gateway';

const port = 3001

const endpointsList = [
  { name: 'PetStore', url: "https://petstore.swagger.io/v2/swagger.json"}
];

const apolloServerConfig = {
  playground: { endpoint: 'gql-gateway' },
  introspection: true // Should be true by default
}

const localSchema = `
  extend type Order {
    pet: Pet
  }
`

const resolvers = {
  Order: {
    pet: {
      fragment: '... on Order {petId}',
      async resolve (order, args, context, info) {
        const schema = await context.resolveSchema('pet_service')

        return info.mergeInfo.delegateToSchema({
          schema,
          operation: 'query',
          fieldName: 'getPetById',
          args: { petId: order.petId },
          context,
          info
        })
      }
    }
  }
}


gateway({ localSchema, resolvers, endpointsList, apolloServerConfig }).then((server) => {
  server.listen(port).then(({ url }) => {
    console.log(`Server ready at ${url}`);
  })
})

ApolloServer

const { ApolloServer } = require('apollo-server');
const { ApolloGateway, IntrospectAndCompose } = require('@apollo/gateway');


const gateway = new ApolloGateway({
    supergraphSdl: new IntrospectAndCompose({
        subgraphs: [
            { name: 'PetStore', url: 'http://localhost:3001'}
        ]
    }),
})

const server = new ApolloServer({
    gateway
})

server.listen({ port: 4004 }).then((server) => {
    console.log(`🚀 Gateway ready at ${server.url}`);
}).catch(err => {console.error(err)});
@segpacto
Copy link
Owner

Hello @acdoyle630

You can take a look at #21 where it is explained how to enable introspection.
Let me know if that solves your issue.

@acdoyle630
Copy link
Author

Thanks @segpacto

I tried enabling introspection in as part of the apolloServerConfig but I'm still getting a bad request. I updated the issue with an updated gql file. Any idea what might be missing?

@segpacto
Copy link
Owner

segpacto commented Apr 21, 2022

Hello @acdoyle630

After some digging we realize that is a feature attached to Apollo Federation subgraph specification, a feature for which the package was not initially developed for.
At the same time we also realize this a nice to have.

For the moment what can we suggest, use the schema specification and add this to the localSchema property on the gql-gateway server .

Meanwhile, we will take a look at how to approach this in order to make it automatically included when there is the need to create a subgraph

@segpacto segpacto added enhancement New feature or request help wanted Extra attention is needed labels Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants