Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

fix: 'Invalid Syntax : offending token '<EOF>'' when using Apollo persisted queries #666

Merged

Conversation

ObeyYourMaster
Copy link

(reopening of #653)
Hi, I've opened a pull request in https://github.com/graphql-java-kickstart/graphql-java-servlet as well, this fix depends on it. This pull request should fix the following issue:

When using Apollo persisted queries via angular-apollo I get the following error in browser console:
Invalid Syntax : offending token '<EOF>'

And the following in server console:
notprivacysafe.graphql.GraphQL : Query failed to parse : ''

Minimal reproduction: https://github.com/ObeyYourMaster/graphql-kickstart-spring-boot-apq-not-working-showcase

My angular setup:

package.json

{
  "@apollo/client": "3.3.20",
  "crypto-es": "1.2.7",
  "apollo-angular": "2.6.0"
}

ApolloClient setup:

export function createApollo(httpLink: HttpLink): ApolloClientOptions<any> {
  return {
    link: createPersistedQueryLink({
      sha256: (...args) => CryptoES.SHA256(...args).toString(),
    }).concat(httpLink.create({
      uri: environment.graphqlEndpoint,
    })),
    cache: new InMemoryCache(),
    defaultOptions: {
      query: {
        fetchPolicy: 'network-only'
      }
    }
  };
}

Used graphql-spring-boot versions:

        <dependency>
            <groupId>com.graphql-java-kickstart</groupId>
            <artifactId>graphql-kickstart-spring-boot-starter-webflux</artifactId>
            <version>11.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.graphql-java-kickstart</groupId>
            <artifactId>graphql-kickstart-spring-boot-starter-tools</artifactId>
            <version>11.1.0</version>
        </dependency>

Please let me know your feedback/comments/thoughts in order to have the fix merged :)

@oliemansm oliemansm merged commit 92c28bf into graphql-java-kickstart:master Aug 19, 2021
@oliemansm
Copy link
Member

Thanks @ObeyYourMaster !

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

Successfully merging this pull request may close these issues.

None yet

3 participants