apollographql / apollographql/apollo-tooling

Setup apollo graphql server for VS code

Open
#2,119 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

:spiral_notepad: component - vscode
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

Hi, Im looking to setup apollo graphql extension in VS code, I've read the other similar issues and have tried all combinations in the apollo.config.js file with no luck, the documentation has detailed info on client setup but could not find for server, please advice?

I have the apollop.config.js as

module.exports = {
    service: {
        localSchemaFile: 'graphql/schemas/*.graphql',
        // excludes: ['node_modules/**/*'],
        // includes: ['**/*.graphql'],
    },
};

I have 6 .graphql files under ./graphql/schemas

./graphql/schemas/checkout.graphql
./graphql/schemas/device.graphql
./graphql/schemas/otp.graphql
./graphql/schemas/plan.graphql
./graphql/schemas/porting.graphql
./graphql/schemas/root.graphql

My root.graphql looks like

type RootQuery {
    OTP(msisdn: String): OTP
    operator(msisdn: String!): Operator
    portingTime: PortingDateTime
    plans(planIds: [String!]): [Plan!]
    securityQuestions: [SecurityQuestion]
    customerDetails(prospectUuid: String): CustomerDetail
    deviceList(catalogOfferId: String): [Device]
    deviceDetails(deviceId: String): DeviceDetails
}

type RootMutation {
    validateOTP(otpUuid: String!, otp: String!): Boolean!
    createPortIn(portInInput: PortInInput): String
    updateCustomerDetail(
        prospectUuid: String
        customerDetailInput: CustomerDetailInput
    ): CustomerDetail
    termsAndConditions(
        prospectUuid: String
        termsAndConditionsStatusInput: TermsAndConditionsStatusInput
    ): TermsAndConditionsStatus
}

schema {
    query: RootQuery
    mutation: RootMutation
}

and my otp.graphql looks like

type OTP {
    otpUuid: String
}

Auto complete does not work and I see this in the logs

(node:13000) UnhandledPromiseRejectionWarning: Error: Unknown type: "OTP".
    at getNamedType (d:\Users\savishnu\.vscode\extensions\apollographql.vscode-apollo-1.16.8\node_modules\graphql\utilities\extendSchema.js:355:13)
    at getWrappedType (d:\Users\savishnu\.vscode\extensions\apollographql.vscode-apollo-1.16.8\node_modules\graphql\utilities\extendSchema.js:370:12)
    at buildFieldMap (d:\Users\savishnu\.vscode\extensions\apollographql.vscode-apollo-1.16.8\node_modules\graphql\utilities\extendSchema.js:404:17)
    at fields (d:\Users\savishnu\.vscode\extensions\apollographql.vscode-apollo-1.16.8\node_modules\graphql\utilities\extendSchema.js:554:22)
    at resolveThunk (d:\Users\savishnu\.vscode\extensions\apollographql.vscode-apollo-1.16.8\node_modules\graphql\type\definition.js:478:40)
    at defineFieldMap (d:\Users\savishnu\.vscode\extensions\apollographql.vscode-apollo-1.16.8\node_modules\graphql\type\definition.js:690:18)
    at GraphQLObjectType.getFields (d:\Users\savishnu\.vscode\extensions\apollographql.vscode-apollo-1.16.8\node_modules\graphql\type\definition.js:631:27)
    at collectReferencedTypes (d:\Users\savishnu\.vscode\extensions\apollographql.vscode-apollo-1.16.8\node_modules\graphql\type\schema.js:366:81)
    at new GraphQLSchema (d:\Users\savishnu\.vscode\extensions\apollographql.vscode-apollo-1.16.8\node_modules\graphql\type\schema.js:148:9)
    at Object.extendSchema (d:\Users\savishnu\.vscode\extensions\apollographql.vscode-apollo-1.16.8\node_modules\graphql\utilities\extendSchema.js:82:53)
(node:13000) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 37)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with apollo.config.js and the schema files under graphql/schemas, especially root.graphql and otp.graphql, then trace how the VS Code extension loads and combines them. Confirm the schema is accepted without the Unknown type: "OTP" error and that autocomplete works across the files.

Written by the indexing model from the issue text.

Assessment

Tech stack
vscode
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.