GraphQL Using the Apollo Framework: Getting Started | raywenderlich.com

In this Apollo Framework for iOS tutorial, you will learn how to consume GraphQL APIs in a simple and type-safe way.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/10886648-graphql-using-the-apollo-framework-getting-started

Don’t know why I got this error message Error loading data networkError

Would you kindly elaborate on the problem a bit further?

That seems to be an error in FilmsViewController line 72, which might, at a glance, indicate there was perhaps problems with the connection or no connection at all.

What other information does the error provide? What was the status of your network connection at that point, and are you able to connect to the API outside of the iOS app? :slight_smile:

I am getting the following error:
→ Error initializing Apollo GraphQL project “Unnamed Project”: Error: Error in “Loading schema for Unnamed Project”: Error: Unable to read file schema.json. ENOENT: no such file or directory, open ‘schema.json’
› Error: Error initializing Apollo GraphQL project “Unnamed Project”: Error:
› Error in “Loading schema for Unnamed Project”: Error: Unable to read file
› schema.json. ENOENT: no such file or directory, open ‘schema.json’

That sounds like your schema.json file is missing. In order for your model to get generated, and do the behind-the-scenes magic, you need to have that file there and in correct formatting prior to building and running.

Have you confirmed it’s there as well as it’s location? :slight_smile:

Just FYI, you can run your queries on SWAPI single endpoint → “https://swapi-graphql.netlify.app/.netlify/functions/index

No need to run your own local or remote server.

Thanks for the tutorial. This was a good intro to GraphQL.

A couple of suggestions. You should probably explain how to get a schema.json a bit further. Plus some more information about features of GraphQL would have made this tutorial better. Like adding authentication to GraphQL requests, passing values in parameters.

The project does not compile with the latest version of Apollo, 0.9.5. It has to be reset to 0.28.0 to compile and set to EXACT version. None of the dependencies for Apollo are resolved either.

At this section: Populating the Films Screen

Not sure about if we are supposed to do anything with the schema.json file. There are no instructions to copy it into the app, just that “we can find it here”.

Apollo 0.9.5 is being loaded in the Swift package.

After I added the Code Generator Script and completed Populating the Films Screen, building on Xcode 13.4 to an iOS 15.5, Simulator iPhone 11, these build errors appear.

/Users/zav/Library/Developer/Xcode/DerivedData/JediArchives-dmakkcatqigplwaiqiajhowubqfu/SourcePackages/checkouts/apollo-ios/Sources/Apollo/Collections.swift:65:17: error: cannot convert parent type ‘EnumeratedSequence<[Key]>’ to expected type ‘EnumeratedSequence<IndexingIterator<Array>>’
keyIterator = base.keys.enumerated().makeIterator()
^
/Users/zav/Library/Developer/Xcode/DerivedData/JediArchives-dmakkcatqigplwaiqiajhowubqfu/SourcePackages/checkouts/apollo-ios/Sources/Apollo/Collections.swift:65:17: note: arguments to generic parameter ‘Base’ (‘[Key]’ and ‘IndexingIterator<Array>’) are expected to be equal
keyIterator = base.keys.enumerated().makeIterator()
^
/Users/zav/Library/Developer/Xcode/DerivedData/JediArchives-dmakkcatqigplwaiqiajhowubqfu/Build/Intermediates.noindex/Apollo.build/Debug-iphonesimulator/Apollo.build/Objects-normal/arm64/ApolloClient.dia:1:1: warning: Could not read serialized diagnostics file: error(“Invalid diagnostics signature”) (in target ‘Apollo’ from project ‘Apollo’)
Command CompileSwift failed with a nonzero exit code

How to pass only present value in a query like I have a total 10 value need to pass but when I am applying filter at that time passing less than 10 value so is it possible to check. In Android I have checked there is one option to pass present value. like Optional.present