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

operationId is invalid for swift codegen #1362

Closed
Codebear98 opened this issue Jun 25, 2019 · 2 comments
Closed

operationId is invalid for swift codegen #1362

Codebear98 opened this issue Jun 25, 2019 · 2 comments
Labels
🐦 component - swift 🤖 component - codegen related to the codegen core packages

Comments

@Codebear98
Copy link

  • operationId mismatch with sever due to missing \n in apollo-codegen-swift.

You can find there is \n to separate fragments in apollo-codegen-core

  const sourceWithFragments = [
    operation.source,
    ...Array.from(fragmentsReferenced).map(fragmentName => {
      const fragment = fragments[fragmentName];
      if (!fragment) {
        throw new Error(`Cannot find fragment "${fragmentName}"`);
      }
      return fragment.source;
    })
  ].join("\n");

https://github.com/apollographql/apollo-tooling/blob/master/packages/apollo-codegen-core/src/compiler/visitors/generateOperationId.ts

However in apollo-codegen-swift, the missing \n causing operationId mismatch with server.

if (fragmentsReferenced.size > 0) {
  this.printNewlineIfNeeded();
  this.printOnNewline(
    "public var queryDocument: String { return operationDefinition"
  );
  fragmentsReferenced.forEach(fragmentName => {
    this.print(
      `.appending(${this.helpers.structNameForFragmentName(
        fragmentName
      )}.fragmentDefinition)`
    );
  });
  this.print(" }");
}

https://github.com/apollographql/apollo-tooling/blob/master/packages/apollo-codegen-swift/src/codeGeneration.ts

@designatednerd
Copy link
Contributor

@Codebear98 Is this any better with iOS 0.13.0 (calling through to tooling 2.16) that's adding the trailing newline now?

@Codebear98
Copy link
Author

checked apollo-ios 0.13.0 don't have such issues anymore, operationID is now valid! @designatednerd thanks for the upgraded!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐦 component - swift 🤖 component - codegen related to the codegen core packages
Projects
None yet
Development

No branches or pull requests

3 participants